active directory script to add users to active directory

jsctechy used Ask the Experts™
need to add about 150 users to active directory (windows 2008 r2)
anyone have a good script that will allow me to add these in a bulk format from excel?
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Krzysztof PytkoSenior Active Directory Engineer
Top Expert 2012

From Excel no, but from CSV file generated from Excel yes. You can use PowerShell for that. If you are interested, please provide some Excel file details to be able to prepare script for you

Most Valuable Expert 2012
Top Expert 2014

There's an example of readin an Excel spreadsheet to create users here:


Depends if the users want to keep their passwords or not. If they do, I would recommend using the following tool to import users to any active directory schema. It is a free tool and already included with Windows Server 2008R2. Why duplicate something that is already done for you?

Retired Scripting Guy

I use the following for tets accounts.
prepare tab delimited file with following fields (export from excel)
Test with one user, to see what fields you need.
I use the spreadsheet to give each user a different password.

Last      First      UserID      PW            Desc

add any fields (usr attributes you want ( New-QADUser  line))  run script below.
modify for you domain

#OU to create users in  
$OU = "OU=TestAccounts,dc=mmycompany,dc=com"
$count = 0

#csv to import
import-csv scm.txt -Delimiter "      "  | ForEach-Object{
$count = 0
#combine fields for data

$displayname = $_.First+ " "+$_.Last #combine first and last names

    #create ID
    write-host "User ID being Created",$samaccountname,$count
    New-QADUser -ou $OU -Name $displayname -Description $_.Desc -UserPassword $_.PW -SamAccountName $_.userid `
      -FirstName $_.First -LastName $_.Last `
      -UserPrincipalName "$($_.userid)"

This is what I use ..just update the Excel sheet with your users info and your ready to go .

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial