Bulk Import Users into Active Directory from CSV

When it comes to IT, automation is your friend. Creating users in your active directory domain is no exception.

Not only does bulk creation of user accounts save you time it also opens the door to delegating the work to other people.

I’d like to share with you a couple really simple ways to bulk import user accounts. The first will be using PowerShell to create active directory users. The second will be to use a simple and free GUI tool for adding users to active directory from CSV.

Using PowerShell to Create AD User Accounts from CSV Sheet

Before starting, ensure you’re working from either a server with the AD role enabled such as a Windows Server Domain Controller or a workstation that’s running the Microsoft Remote Server Administration Tools.

Download the pre-formatted CSV sheet and PowerShell script to create users in active directory here.

1. Fill in the Required Fields in the CSV Sheet

Start by opening the downloaded CSV sheet (or creating your own) and filling out the required fields. These fields are:

firstname,lastname,username,password,ou

Screenshot showing import users powershell csv required fields

While it’s technically possible to leave the password blank, this will result in the user account being created in a disabled state and will require a password be set before the account can be enabled.

Properly Formatting the OU Field

If you open the CSV download provided you’ll see an example of the OU path syntax.

Screenshot showing import users powershell csv ou

You can also find this by:

  1. Opening Active Directory Administrative Center
  2. Opening the Properties of your desired OU
  3. Clicking Extentions -> Attribute Editor
  4. Navigating to the distinguishedName attribute
  5. Copying the Value to the OU field in the CSV sheet
Screenshot showing OU distinguishedName attribute editor

2. Optionally Fill Out the Remaining Fields

The CSV file contains optional fields that you can fill in with relevant data. If you’re creating your own CSV sheet these fields are:

email,streetaddress,city,zipcode,state,county,description,office,department,telephone,jobtitle,company

Feel free to add or remove fields from the sheet. Just be sure to remember to add or remove them from the script as well (it’s really easy).

3. Save the CSV File

Save your file to a known location. You’ll need to open the PowerShell script and update the “$ADUsers = Import-csv” line to include the full path to the file.

4.  Update the PowerShell Script with the Path to the CSV

As mentioned in step 3, we need to let the script know where we saved our CSV file. Right click the PowerShell script file and click Edit.

Find the line starting with “$ADUsers = Import-csv” (it should be line 11 in an unmodified version of the scrip file) and append it with the full path like so:

$ADUsers = Import-csv C:\temp\NewADUsers.csv
Screenshot showing import users powershell csv location

5. Update the PowerShell Script UPN Setting

Before we can run the script we need to make one last update to it. We need to set the domain to be used for the UPN when creating the accounts.

Find the last block in the PowerShell script and update the “-UserPrincipalName line (line 48) with your domain like so:

-UserPrincipalName "$Username@npgdom.com" `
Screenshot showing import users powershell csv upn

Save the file.

6. Run the PowerShell Script to Create AD Users

Open PowerShell, change your directory to the location of the script, and run script by entering:

.\NewADUsers.ps1
Screenshot showing import users ad powershell script

You can also edit the PowerShell script and click the play button within PowerShell ISE if you prefer.

At this point you should either be returned to the prompt (if the script run was successful) or receive a warning if any accounts existed already or there were any problems with the script.

You can verify the account created by navigating to the OU you specified in your CSV sheet and looking for the new accounts.

Use Free GUI Tool to Import Users into Active Directory

If you’re not the scripting type, or just prefer GUI tools (no shame in that), you’ll be glad to know there are quite a few free options that work great. One of the easiest to use is SolarWinds User Import Tool  which is part of their free Active Directory Admin Tools Bundle.

Simply download the bundle and run the UserImportTool.msi to install the tool.

Screenshot showing solarwinds user import tool

1. Prep Your CSV Sheet

I have uploaded a preformatted sheet here. You just need to fill out the relevant fields keeping in mind the required ones:

Given-Name,Surname,Sam-Account-Name,Password

Screenshot showing solarwinds user import tool csv

2. Run the User Import Tool

Launch the Solarwinds User Import Tool and select your CSV sheet within the tool. Select the appropriate radio button for Account Type and then enter your domain credentials (account must have rights to write to active directory).

Click next.

3. Map Your Fields

The next screen will ask you to map the fields from the CSV sheet. Since the fields in the sheet I provided are already named appropriately it should be pretty easy to match them up.

You also need to be aware that any field you map from your sheet will become a required field in the tool. Make sure any field you map is filled out for each user in the CSV file.

Click next.

4. Set Your OU

The next screen has a field at the top for specifying the OU you wish to create your user accounts in. Click Set to set the OU.

5. Create Your AD User Accounts

At this point you just need to verify everything in the preview looks correct and click Create.

Just as before, you can verify the accounts were created by navigating to the OU you specified and look for the new accounts.

Hopefully this tutorial was easy to follow and saves you time and heartache in the future.

Recommended Tool: ManageEngine OpManager

  • Multi-vendor Network Monitoring
  • Simple Installation & Setup
  • Intuitive UI
  • Complete Visibility
  • Intelligent Detections
  • Easy Resolutions

2 Comments

  1. Avatar Michael Galarza says:

    Can you adjust the script to include proxyAddresses field?

  2. Avatar Steve Jordan says:

    Keep in mind if you have a special attribute that is not support by the normal Add-ADUser parameters you need to use -OtherAttributes command. For instance adminDescription attribute is not recognized natively by the Add-ADUser, so you would use: -OtherAttributes @{‘adminDescription’=$adminDescription}

Leave a Reply

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