Creating User Accounts from a CSV (Comma Separated Value) File
In this lecture, I am going to be showing you how you can create active directory users from a CSV file.
I am going to show you how the CSV file looks like and you can find it in the resources of this lecture called NewUsers.csv.

You can see header fields like First Name, Last Name, Job Title, Office Phone, Email Address, Description, the target Organizational Unit or where they need to be placed within Active Directory and whether or not the account should be Enabled once it's created.
So, we are going to use PowerShell to automatically create all these user accounts. These are just 10 users here but if we were working with 500 or a thousand this will also work.
Log into the IPDC01 server and I have the file already saved into my E:\ drive.

We open Windows PowerShell ISE by clicking on the Windows icon on the bottom left and typing powershell and selecting Windows PowerShell ISE.

And the Windows PowerShell ISE opens up.

Let’s start typing out the script with the following:
Import the AD Module
Import-Module ActiveDirectory
Get the path to our target CSV file
$filepath = Read-Host -Prompt "Please enter the path to the CSV file that contains the new user accounts"
Import the CSV as an array
$users = Import-CSV $filepath
Press the Play button to execute the script.
Note that in the bottom pane we have the script executed and it is asking for the path to the CSV so we type in E:\NewUsers.csv and press the Enter key on your keyboard.
The script finishes executing.
No comments yet. Add the first comment to start the discussion.