Prerequisites :
- A list of users in the format of .csv file as shown.
- The user logon name or the SAM account name should be different for different users.
- A desired OU as mentioned in the CSV file to be created in the Active Directory
Run > dsa.msc > Right click on the domain > New > Organizational Unit

Procedure :
The following powershell code is used to create the bulk users in the Active Directory.
Import-Module ActiveDirectory
$securePassword = ConvertTo-SecureString "123456aA#" -AsPlainText -Force$filepath = Read-Host -Prompt "Please enter the path to your CSV file"
$users = Import-Csv $filepath
ForEach ($user in $users) {
$name = $user.'Display Name'
$fname = $user.'First Name'
$lname = $user.'Last Name'
$intials = $user.'Intials'
$department = $user.'Department'
$userlogonname = $user.'User Logon Name'
$OUpath = $user.'Organizational Unit'
$Sam = $user.'SamAccount Name'
New-ADUser -Name "$name" -GivenName "$fname" -SurName "$lname" -Initials $intials -Department "$department" -UserPrincipalName "$userlogonname" -SamAccountName "$Sam" -Path $OUpath -AccountPassword $securePassword -ChangePasswordAtLogon $True -Enabled $True
}
- Mention the Path of the CSV file and click ENTER, which results in the creation of the users according to the CSV file.
- For the Verification, check the mentioned Organizational Unit in the Active Directory for the Users.
Modification of any attributes of the users in bulk
The following powershell code can be used for the modification of the user attributes in bulk, for example to change the SamAccount Name and Company of the Users in Bulk using CSV file.
Import-Module ActiveDirectory $filepath = Read-Host -Prompt "Please enter the path to your CSV file" $users = Import-Csv $filepath ForEach ($user in $users) {Get-ADUser -Filter "UserPrincipalName -eq '$($user."User Logon Name")'" | Set-ADUser -SamAccountName ($user."SamAccount Name") -Company ($user."Company")}
And the sample format of the CSV file for the modification process can be as followed

Secondary Domain Controller (ADC)
Any Administrative operation can be performed in any of the domain controllers, but it is preferred to make action in the secondary domain controller
