PowerShell New-ADUser

Download the Attached Source File for Formatted Example Sheet

Copy to C:\temp & Rename File to "User_Accounts.csv" 

Replace entries with your data, do not modify headers of csv

Run Script Below:

Try{

$Count=0

$MyAccounts=Import-csv C:\temp\User_Accounts.csv -ErrorAction Stop

Foreach($Account in $MyAccounts){

    $FullName="$($Account.Firstname) $($Account.Lastname)"

    New-ADUser -server $Account.ServerName -Name $FullName -SamAccountName $Account.Samaccount -DisplayName $FullName -GivenName $Account.FirstName -Surname $Account.LastName -UserPrincipalName $Account.UPN -Enabled $true -ChangePasswordAtLogon $False -AccountPassword (ConvertTo-SecureString -AsPlainText "$($Account.PassWord)" -Force) -passthru -PasswordNeverExpires $True -CannotChangePassword $True -Description  $Account.Description -Company "Scripts By Scott" -Path $Account.OU -ErrorAction Stop 

    $Count=$Count+1


}}Catch{

    Write-Output "`n`n#$Count $($Account.Samaccount) - $FullName - Was the Account Entry with an Error"

    Write-Output "All accounts prior to this in the list have been created"

    Write-Output $_.Exception 

}

Source File Here

2020 | Scott W. Head  |  Sr. Systems Admin | Certified Microsoft Windows Server Administrator