Create AD multiple user accounts using PowerShell

Many times we come across a scenario where we need to create bulk of AD user accounts. But who wants to spend a whole bunch of time for creating users? So we at Deskperts went ahead and made a PowerShell Script that will create users from a CSV file. Hope you find it useful!!!!

We have tested the below script in Windows Server 2008 R2 AD infrastructure.

We have created a test OU as Sales in our testlab.com with no users.

Below is the Powershell script in text format to create bulk users in AD.


        Note:- Save the file with .PS1 format (Powershell)
        The Script data is below, copy the below text into Notepad, and save it as Original.ps1

Import-Csv .\Original.csv | foreach-object {
$UserPrincipalName = $_.SamAccountName + “@TESTLAB.COM”

New-ADUser -SamAccountName $_.SamAccountName -UserPrincipalName $UserPrincipalName -Givenname $_.FirstName -Name $_.FirstName -DisplayName $_.DisplayName -SurName $_.LastName -Department $_.Department -EmailAddress $_.EmailAddress -EmployeeID $_.EmployeeID -Path $_.Path -AccountPassword (ConvertTo-SecureString “pass@123” -AsPlainText -force) -Enabled $True -ChangePasswordAtLogon $True -PassThru }       

Create the csv file with user properties to be created in AD as below.


Note: – Give the csv file name same as 1st line in the script.

Copy both files at same location on AD.

To run the script on AD:
  • Run Active Directory Module for PowerShell as Administrator
  • Change to the location where you have placed the Script and the CSV file.
  • Now run the script. Type “.\CreateAccount.ps1”

 AD Users will be created as below.

10 thoughts on “Create AD multiple user accounts using PowerShell”

  1. I attempted to use this code to create 100 users, but I received the following error. Have you run into it and do you know a solution?ThanksThe term 'New-ADUser' is not recognized as the name of a cmdlet, function, script file, or operable program. Check thespelling of the name, or if a path was included, verify that the path is correct and try again.At C:\\Users\\dbcot\\users.ps1:4 char:11+ New-ADUser <<<< -SamAccountName $_.SamAccountName -UserPrincipalName $UserPrincipalName -Givenname $_.FirstName -Name $_.FirstName -SurName $_.LastName -Path $_.Path -AccountPassword $_.AccountPassword -Enabled $True -ChangePasswordAtLogon $True -PassThru } + CategoryInfo : ObjectNotFound: (New-ADUser:String) [], CommandNotFoundException + FullyQualifiedErrorId : CommandNotFoundException


  2. Are you using the Active Directory Module for Windows PowerShell??? If not you have to import it with Import-Module cmdlet.


  3. The cmdlets for Active directory:import-module ActiveDirectoryYou may be able to put this in to the .ps1 file specified above.


  4. Is there a way to add a password value and import it too?How will the PowerShell and CSV file should be?Thanks in advance!!!


  5. I attempted to use this code to create 50 users, but I received the following error. Have you run into it and do you know a solution?ThanksNew-ADUser : Cannot validate argument on parameter 'Name'. The argument is null or empty. Supply an argument that is not null or empty and then try the command again.At C:\\temp\\Add-NewUsersDesarrollo.ps1:4 char:21+ New-ADUser -Name <<<< $_.DisplayName -SamAccountName $_.SamAccountName -GivenName $_.FirstName -Surname $_.LastName -DisplayName $_.DisplayName -Description $_.Description -EmployeeID $_.EmployeeID -UserPrincipalName $userPrinc -AccountPassword (ConvertTo-SecureString -AsPlainText \”TBcBviV6\” -Force) -Enabled $true -path \”OU=PruebasVS,DC=desarrollocolpatria,DC=com\”} + CategoryInfo : InvalidData: (:) [New-ADUser], ParameterBindingV alidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Activ eDirectory.Management.Commands.NewADUser


  6. have a look here for advanced active directory objects(users,computer,group,contact,OU,etc) creation/modification/deletionhttp://www.adsysnet.com/asn-active-directory-manager-bulk-objects-creation.aspx


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s