Import [Create] Bulk AD User Using Powershell Scipt The Best Script Ever !, Ad Multiple Active Directory users very Quickly. 

1 answer

Staff June 27, 2016

This script is best because you have very little things to do in Excel Just have First Name and last name in the csv sheet.
FirstName, LastName
Jon, Snow
Remember To set OU path in the script and SamaccountName(username) based on your environmentm and save in C drive as users.csv that contains list of users with FisrtName and Lastname.

$Users=Import-csv c:\users.csv

ForEach($User in $Users)
$FullName = $User.FirstName + ” ” + $User.LastName
$SAM = $User.FirstName.Substring(0,1) + $User.LastName #example John snow will be Jsnow
#$Sam=$User.FirstName+$User.LastName example john snow will be Johnsnow
#$Sam=$User.FirstName example john snow will be John
#$Sam= $User.firstName + “.” + $User.lastName example john snow will be John.snow
$dnsroot = ‘@’ + (Get-ADDomain).dnsroot
$UPN = $SAM + “$dnsroot “
$OU=”CN=users, DC=Domain,DC=COM”
$email=$Sam + “$dnsroot ”
New-ADUser -Name $FullName -AccountPassword (ConvertTo-SecureString “Password!1234” -AsPlainText -force) -GivenName $User.FirstName -Path $OU -SamAccountName $SAM -Surname $User.LastName -UserPrincipalName $UPN -EmailAddress $Email -Enabled $TRUE}
Write-Host “created $FullName”


Please login or Register to Submit Answer