Importing Users using PowerShell

By |2017-12-07T12:12:24+00:00November 3rd, 2011|PowerShell|0 Comments

We had a request from on of our clients where they wanted to create new user accounts for around 50 new employees. In order to do this we created a simple PowerShell script that used a populated CSV file to create the users in a certain OU and with a default password.

The CSV file had the following headings:


After saving it to a location we ran the following PowerShell script that created the users:


import-module activedirectory
$inputFile = Import-CSV  C:usersToBeCreated.csv

foreach($line in $inputFile)
new-aduser -SamAccountName $line.UserName -Name $line.FullName -AccountPassword (ConvertTo-SecureString -AsPlainText "Password" -Force) -Enabled $true -Path "OU=Domain Users,DC=TEST,dc=LOCAL" -DisplayName $line.FullName -GivenName $line.FirstName -Surname $line.SurName -UserPrincipalName $line.UserPrincipalName -ChangePasswordAtLogon $True


You can copy and paste the script above where you will only need to change the bold text which is the CSV location, the temporary password for the new users and the OU that you want to put the users into.

As long as you use the same headings in your CSV file then this should work ok. You can, of course add in more details that are accepted by the new-aduser command which are outlined in the URL below:



Leave A Comment

like what you see? 

Sign-up to our newsletter and never miss out on the latest blogs, events and tech news from the world of risual
Give it a try, you can unsubscribe anytime.