Import Users Into Active Directory From CSV

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.

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

You may also like:

AD Account Keeps Locking Out Sometimes there are situations when AD account keeps locking out, this happen when you try to log on to a domain computer and getting an error on the ...
Installing Active Directory Users and Computers MM... One of the main Active Directory domain management tools is the MMC snap-in Active Directory Users and Computers (ADUC). The ADUC snap-in is used to p...
How to transfer FSMO Roles From a Failed Domain Co... In case domain controller, which owns FSMO (Flexible Single Master Operation) roles, is fail (virus attack, fatal software problems or catastrophic ha...
Store BitLocker Recovery Keys using Active Directo... In a domain network, you can store the BitLocker recovery keys for encrypted drives in the Active Directory Domain Services (AD DS). This is one of th...
Fix: Active Directory Domain Controller Could Not ... In this article, we’ll take a look at why it’s not possible to join a new computer to the Active Directory domain with an error Active Directory Domai...
  1. Posted by Michael van Ballegoie

Add Your Comment