Import Users Into Active Directory From CSV

If you need to create many new user accounts in a domain at once, it is extremely inefficient to create them all manually from the graphical console Active Directory Users and Computers (ADUC). In this article, we will take a look at a simple PowerShell script that allows you to import user data from a CSV/XLS file and create accounts for them in the Active Directory domain.

First of all, create a NewUser.xlsx file in Excel with the following header structure:


Fill the Excel file with the data of all users that you want to create in Active Directory (usually this data is provided from the personnel accounting system).

import users into active directory from csv

Export the Excel file to CSV format with commas as separators (File > Save as > File type: CSV, File name: new_as_users.csv). If you want to use “;” as a separator, you need to add the following argument to the Import-CSV cmdlet -delimiter “;”.

import users into active directory

To create new users in the domain, we will use the New-ADUser cmdlet from the Active Directory for Windows PowerShell module, so before running the PowerShell script, make sure that this module is installed on the server/computer from which you are performing users import.

Create an import_ad_users.ps1 file with the following PowerShell code (change the name of your domain and the Active Directory Organizational Unit (OU) in which you want to create users):

Import-Module ActiveDirectory



$NewUsersList=Import-CSV "C:\PS\new_as_users.csv"

ForEach ($User in $NewUsersList) {














New-ADUser -PassThru -Path $UserOu -Enabled $True -ChangePasswordAtLogon $True -AccountPassword (ConvertTo-SecureString $userPassword -AsPlainText -Force) -CannotChangePassword $False -City $City -Company $Company -Department $Department –title $title –OfficePhone $telephoneNumber -DisplayName $FullName -GivenName $givenName -Name $FullName -SamAccountName $sAMAccountName -Surname $sn -UserPrincipalName $userPrincipalName


Note. Options-ChangePasswordAtLogon $True requires changing the user password at the first login, -CannotChangePassword $False – allows the user to change passwords by himself. If you create service accounts, you can specify -ChangePasswordAtLogon $False, -CannotChangePassword $True.

READ ALSO  PowerShell Function Parameters: How to Add?

Run the script from the PowerShell command prompt, then open the ADUC console and make sure that new users appeared in the specified OU.

import users into active directory from csv powershell

As you can see, this PowerShell script allows the mass import of users into Active Directory in a few minutes. You can remove or add any user attributes to the script and CSV/Excel file from AD. A complete list of available user attributes in your domain schema can be displayed using the following cmdlet:

Get-ADUser –identity administrator –filter * -properties *|fl

import contacts into active directory

Cyril Kardashevsky

One comment

  1. Once all users are imported and for example a users is changing department and jobtitle i want to update the .csv file with the right information and run the .ps1 script to apply the changes.
    Note all other settings needs to be intact, so the script should only check the changes made in the .csv file.

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.