Today at work I was handed a list of names that all needed accounts created on Active Directory. They all needed the same regular user account permissions and even used the same password. I decided instead of going through Active Directory I would just write a script that would allow me to enter a first name, last name and password and the account would be created for me.

I would have written something to import the list, except for the fact that the list I was given was in paper form so I decided I could just type in the names once and be done.

Prequisite: Installing RSAT

In order to get started you need to make sure you have the Active Directory module that is a part of the RSAT (remote server administration tools) installed. This must be enabled before you can start using Powershell with Active Directory. You can enable RSAT on Windows 10 by pressing the Windows key and searching for “Features”. Select the Turn Windows features on or off option.

If you are on Windows Server you can simply click Manage > Add Roles and Features from Server Manager and navigate to the Features screen. Make sure the Active Directory module for Windows Powershell is checked and click Next and complete the feature installation.

You can figure out if you have the Active Directory module installed by opening Powershell and entering the command:

Import-Module ActiveDirectory

Writing the PowerShell script

Once you have the Active Directory module installed, it’s time to open the ISE and write some code. Click the Windows button and search for Powershell.

Once the PowerShell ISE loads you will be able to start writing the code needed to create user accounts. You may need to click the Script drop down arrow so you can write and save your code.

The basic code you need to write create a new user account in Active Directory with Powershell is the “Import-Module ActiveDirectory” and “New-ADUser”:

Of course make sure you are logged in as a domain administrator otherwise you will be unable to execute the New-ADUser command.

PowerShell Script

I have created a powershell script at work today that will allow you to repeatedly create user accounts and place them in the Users OU. On line 18 you want to change the OU path to reflect your domain name. I was using this script on my domain so you will need to change the “DC=itflee” to whatever your domain is named.

Click green play button  to run the script.  I am going to create a user account for Paul Hill (myself) with the password of Password1.


Now if you start up Active Directory Users and Computers you will see the user account has been created!



Get Your Free Video Course!

Get the premium video course titled "Build Your Own Windows Server IT Lab" for free by subscribing to our newsletter!

Confirm your email address and we will send you the course!