active directory script to add users to active directory

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?
jsctechyInfrastructure Team LeadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Krzysztof PytkoSenior Active Directory EngineerCommented:
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

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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 .
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Active Directory

From novice to tech pro — start learning today.