You can create multiple AD users from a csv file using a PowerShell script. This script is most suitable in scenarios where new students or employees join the company in batches and creating users one by one is too time consuming.

This script is written to serve this purpose and it assumes you have users (GivenName, LastName, samAccountName, EmailAddress) in aCSV file. I have used the following cmdlets in the code:

  • import-csv (For reading users information from CSV file).
  • new-aduser (For creating an AD user).

PowerShell AD user import from CSV script

Step 1. Open a text file and copy/paste the following script. Save it with .ps1 extension

$UsersFilePath = "C:\Users\Administrator.YOURDOMAIN\Desktop\WC\users.csv" # Files of users information (First name, Last name, Sam account name, Email address)

import-csv -path $UsersFilePath | foreach {

$Name = ($_.GivenName + " " + $_.LastName)

$UserPrincipalName = ($_.SamAccountName + ””)

#Create user in Students OU

new-aduser -name $Name -enabled $true -GivenName $_.GivenName –surname $_.lastName -changepasswordatlogon $true -samaccountname $_.SamAccountName –userprincipalname $UserPrincipalName -EmailAddress $_.EmailAddress -Path 'OU=Students,DC=yourdomain,DC=com' -ErrorAction Stop

Step 2. Open PowerShell with elevated privileges and execute the script from step 1

How to Create AD Users in Bulk Using PowerShell

Leave a Reply

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