Create Bulk AD Users from CSV file with OtherAttributes
1. Consider the CSV file NewADUsers.csv which contains set of New AD Users to create with required Active Directory attributes (i.e. Name, samAccountName and ParentOU).
Note: the value of ParentOU should be enclosed with double quote (“). like “OU=TestOU,DC=TestDomain,DC=Local” since it has the special character comma (,). because in csv file the comma (,) is the key character to split column headers. (Ex file: Download NewADUsers.csv).
2. Copy the below Powershell script and paste in Notepad file.
3. Change the NewADUsers.csv file path with your own csv file path.
4. Change the domain name TestDomain.local into your own domain name.
5. Add more other ad attributes with the parameter -OtherAttributes.
6. SaveAs the Notepad file with the extension .ps1 like Create-Bulk-AD-Users-CSV.ps1
Click to download Powershell script as file Create-Bulk-AD-Users-CSV.ps1
Import-Module ActiveDirectory Import-Csv "C:\ScriptsNewADUsers.csv" | ForEach-Object { Write-Host "Creating AD user:" $_.Name New-ADUser -Name $_.Name ` -Path $_."ParentOU" ` -SamAccountName $_."samAccountName" ` -UserPrincipalName $_."userPrinicpalName" ` -OtherAttributes @{title=$_."JobTitle";mail=$_."userPrinicpalName";proxyaddresses=$_."proxyAddresses"}` -AccountPassword (ConvertTo-SecureString "MyPassword123" -AsPlainText -Force) ` -ChangePasswordAtLogon $true ` -Enabled $true Add-ADGroupMember "Remote Desktop Users" $_."samAccountName"; } Write-Host "---------------------------------" Write-Host "Bulk AD Users created successfully from CSV file." Write-Host "---------------------------------"
7. Now run the Create-Bulk-AD-Users-CSV.ps1 file in Powershell to create Bulk Active Directory users from CSV file.
Note: I have placed the script file in the location C:Scripts, if you placed in any other location, you can change the file path (like “C:\DownloadsCreate-Bulk-AD-Users-CSV.ps1”).
8. Now you can view the newly Created Active Directory Users though ADUC console.