Import bulk users (windows 2008)

Following Windows PowerShell command imports users from .csv file:

import-csv d:\source\User1.csv | foreach-object {new-aduser -Name $_.Name -DisplayName $_.DisplayName  -UserPrincipalName $_.UserLogonName -EmailAddress $_.EmailAddress -sAMAccountName $_.ExchangeAlias -Description $_.Description -surname $_.LastName -givenName $_.FirstName -Enabled $true -ChangePasswordAtLogon $false -AccountPassword (ConvertTo-SecureString “Password123” -AsPlainText -force) -PassThru}

Sample CSV file:

Alex Du,Alex Du,,Networking Engineer,,Alex.Du,Alex,Du

——-Another Example——

Following script entered userprinciplename as 3rd party email address for Active directory authentication.

Import-Csv “c:\parents.csv” | foreach-object {New-ADUser -SamAccountName $_.”SamAccountName” -Name $_.”name” -GivenName $_.”GivenName” -SurName $_.”SurName” -Displayname $_.”Displayname” -Title $_.”Title” -Description $_.”Description” -UserPrincipalName $_.”UserPrincipalName” -AccountPassword (ConvertTo-SecureString “p@ssword88” -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru -Path “OU=Test,dc=yourdomain,dc=local”}

Sample CSV file: save as parents.csv

UserPrincipalName,SamAccountName,Name,Givenname,surname,DisplayName,Title,Description,Salma.hayk,Salma Hayk,Salma,Hayk,Salma Hayk,ICT Support Engineer,Helpdesk Staffs


Name as an email address (applicable where possibility of duplicate name)

Import-Csv “c:\parents1.csv” | foreach-object {New-ADUser -SamAccountName $_.”SamAccountName” -Name $_.”name” -GivenName $_.”GivenName” -SurName $_.”SurName” -Displayname $_.”Displayname” -Title $_.”Title” -Description $_.”Description” -UserPrincipalName $_.”UserPrincipalName” -officephone $_.”Phone” -mobilephone $_.”Cell” -AccountPassword (ConvertTo-SecureString “p@ssword88” -AsPlainText -force) -Enabled $True -PasswordNeverExpires $True -PassThru -Path “OU=Test,dc=yourdomain,dc=local”}

UserPrincipalName,SamAccountName,Name,Givenname,surname,DisplayName,Title,Description,Phone,cell,,,Aisya,Ren,,Director of Marketing APAC,Parents of Renold Rend,65937780,82988572


Note: ensure no trailing blank space on the field name


About Robiul

Robiul has 15 years of continuous successful career experience in ICT with extensive background in System Engineering, IT infrastructure design, operations and service delivery, managing IT projects / MIS functions for local and multi-national companies with in-depth knowledge of multiple operating systems as well as construct / manage small to medium size Data Center. Proven ability to design and implement medium to semi-large scale LAN/WAN/WLAN and system infrastructures. Academic qualification: Master of Science in Information Systems. Professional certifications are: MCSE, CCNA, ITIL and FoundStone Security Professional, VCP, NetAPP, CISSP etc.
This entry was posted in Powershell, Windows and tagged . Bookmark the permalink.