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 Domain Controller or a workstation that’s running the Microsoft Remote Server Administration Tools.
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:
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.
You can also find this by:
- Opening Active Directory Administrative Center
- Opening the Properties of your desired OU
- Clicking Extentions -> Attribute Editor
- Navigating to the distinguishedName attribute
- Copying the Value to the OU field in the CSV sheet
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:
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
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" `
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:
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.
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:
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).
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.
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 for You: Solarwinds Server & Application Monitor (SAM)Know which applications are having issues in your environment before users complain? Know which systems are causing those problems? How about which servers are about to have problems like running out of space or memory?
Automate collection of data and alerting on your applications and servers with Solarwinds Server & Application Monitor so you have these answers.
Get insight into Active Directory, DNS, DHCP, and your Virtual environment without needing to mess with complex templates or knowing a single line of code.