Create User account in Active Directory from Spread Sheet |Import CSV Excel

We have many ways to create users in active directory for example you can create users from command prompt, PowerShell, .LDF, .PS1 files etc. but all these methods are time consuming if you have to create large number of user in very short time. Using CSV file and .PS1 script file we can create a multiple users quickly.


How to create CSV file for creating user accounts in Active Directory:

Create a Excel file and made the following columns in it and fill out your users info, I just added the dummy info into it. After adding user info into excel save this file as CSV.

cn sAMAccountName FirstName LastName
Alex Alex.z Alex z
Sam Sam.j Sam j
Lara Lara.b Lara b
Zara Zara.Eve Zara Eve

Download users.CSV file for creating user accounts using powershell.


How to create Script file for creating user accounts in PowerShell:

We need a .PS1 script file which point to above CSV file and add users from CSV file to active Directory.

Script code for importing users from CSV file to active directory is as follow:


$ou=[ADSI] “LDAP://ou=HR,ou=Department,dc=w7cloud,dc=com”

$dataSource=import-csv “usersdb.csv”

foreach($dataRecord in $dataSource)






$displayName=$sn +”,”+$givenName












$NewUser.Put(“company”, “W7CLOUD”)



Download usersScript.PS1  file for creating user accounts using powershell


Now place both these file on same directory and open the PowerShell as administrator and run the following commands. I have save these two files usersdb.CSV and script.PS1 on my desktop.

PS C:UsersAdministratorDesktop> Set-ExecutionPolicy unrestricted.

PS C:UsersAdministratorDesktop> .script.ps1

After successful running of above 4 user will be appear in HR OU.

Create user accounts with Script CSV

Set-ExecutionPolicy unrestricted command enable the execution of script on your system and 2nd command will run the script file which will imports users from CSV files to active directory.


This first line in script.PS1 is representing the location where user accounts will be create, in our case it is HR OU which is an Sub-OU in Department OU in DC. For more detail you can view the below image and visit create user with PowerShell.

script.ps1+CSV user account


PowerShell Command Syntax | Create Users Account in AD Using PowerShell 

Waqas Azam
Me Waqas Azam and I am a professional blogger & freelance writer. I also working in the IT industry for over 7 years. I am graduated in Computer Science and information technology.