Hi!
Below script will help to create bulk users from CSV file.

1. Prepare CSV file with below Heading
First,Last,FullName,sAM,passwd,Dec
2. Save script as “BulkUsers.ps1”

################## Bulk User Creation From A CSV File ####################
######### Script Created by Muneer Hussain. K [email protected] #########

############ Prepare CSV file with below Heading ######################
########## First,Last,FullName,sAM,passwd,Desc ####################

###### if users to need to different path just add one more column in CSV file with heading path and specify AD path (OU)

Import-Module ActiveDirectory
$Users=Import-csv “path of the CSV file”
$path=”OU path”
$dnsroot = ‘@’ + (Get-ADDomain).dnsroot
ForEach ($User in $Users)
{
$fname=$User.First
$lname=$User.Last
$full=$User.FullName
$sam=$User.sAM
$desc=$User.Desc
$passwd=$User.passw
$upn=$User.sAM+$dnsroot

New-ADUser -Name $full -DisplayName $full -Path $path -PasswordNeverExpires 1 -AccountPassword (ConvertTo-SecureString -AsPlainText $passwd -Force) -SamAccountName $sam -GivenName $fname -Surname $lanme -UserPrincipalName $upn -Description $desc -Enabled 1

Write-Host “User ” $upn “Created Successfully”

}

3. Open PowerShell and run script.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *