Adding Bulk Users in AD

I am trying to find a good way to add bulk users in AD.  I know it can be scripted in powershell but I havent had much luck with that.

I just want to add users, drop them in an OU, set the password and force them to change it at login.

What is the best way to do this, Powershell?  If so, how do you do it in powershell?
This is a Windows 2k8 domain, domain fucntional level at 2k3.

Who is Participating?
Sergey KolesnikIT ManagerCommented:
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

What format do you have the users details in?
Earl28Author Commented:
CSV, and its just FirstName,LastName.
Earl28Author Commented:
Here is what I have, I ripped it off some site, so I didnt write it.  (disclaimer)

$objOU=[ADSI]"LDAP://OU=NewUserDump,OU=CCA Campus,DC=mydomain,DC=local"
$dataSource=import-csv "adduser.csv"
foreach($dataRecord in $datasource) {
$cn=$dataRecord.FirstName + " " + $dataRecord.Lastname
$SAMAccountName=$dataRecord.FirstName + "." + $datarecord.LastName
$displayName=$sn + ", " + $givenName
$userPrincipalName=$SAMAccountName + "@mydomain.local"

$objUser=$objOU.Create("user", "CN="+$cn)


When I run it in powershell, it doesnt like the last 4 lines, in regard to the password.  I removed those lines, the script ran without error, but no user account was created in the specified OU.

I am running the script as Admin in Powershell and have changed the ExecutionPolicy.
Brent ChallisPrincipal: ITCommented:
Here is a script that I have written to create a collection of users based on a csv file.  I am reading more information that you have mentioned form the file so you can prune the code down.  I am using the Department entry in the csv file to both populate the Department property and to put them in an OU of the same name.  This requires the ActiveDirectory web service to be present on the DC.

The headers for the columns of my csv file are:
EmployeeID      Surname      GivenName      Initial      Title      Suffix      JobTitle      Department      Division      EmailAddress      PhoneNumber      SAMAccount      City      PostalCode      StateProvince      CountryRegionCode      Country      UPN
yo_beeDirector of Information TechnologyCommented:
You can also use CSVDE -I switch.
This will create users from a standard csv file.   It is part of windows.
I find it is a bit more straight forward, but learning PS is not a bad way to import and learn scripting.
*** Hopeleonie ***IT ManagerCommented:
We created with CSV, but I think you can choose a format.
You haven't referenced the ou in the create function. You only fill a variable with the ou info..

also its much easier you use the built in function..

Brian PiercePhotographerCommented:
There are lots of free tools available - why re-invent the wheal

Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Creating bulk Active Directory user and group accounts in PowerShell using Server 2008 R2 cmdlet

To create my users in the OU “*****” for the domain “****.local”
Creating groups and assigning members

- Rancy
You can also use batch.
Fire the command dsadd user /? and see what's possible. Try using a for loop on your .csv/textfile.
Earl28Author Commented:
Thanks for all the input.  I ended up using the ANUC tool that dreik mentioned.  It was good, the CSV part was a bit flaky, so I added them manually using the tool.  It took me 2 hours to add 500 users, so not bad.<br /><br />it doesnt allow you to add group membership, if it had that it would be great.<br /><br />Thanks again.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.