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.

TIA
Earl28Asked:
Who is Participating?
 
Sergey KolesnikIT ManagerCommented:
0
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.

 
p_nutsCommented:
What format do you have the users details in?
0
 
Earl28Author Commented:
CSV, and its just FirstName,LastName.
0
 
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
$givenName=$dataRecord.FirstName
$sn=$dataRecord.LastName
$SAMAccountName=$SAMAccountName.ToLower()
$displayName=$sn + ", " + $givenName
$userPrincipalName=$SAMAccountName + "@mydomain.local"

$objUser=$objOU.Create("user", "CN="+$cn)
$objUser.Put("SAMAccountName",$SAMAccountName)
$objUser.Put("userPrinciplaName",$userPrincipalName)
$objUser.Put("dispalyname",$displayName)
$objUser.Put("givenName",$givenName)
$objUser.Put("sn",$sn)

$objUser.SetInfo()
$objUser.SetPassword("password")
$objUser.psbase.InvokeSet("AccountDisabled",$false)
$objUser.SetInfo()
}


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.
0
 
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
CreateUpdateUserAccounts.txt
0
 
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.
http://technet.microsoft.com/en-us/library/cc732101(v=ws.10).aspx
I find it is a bit more straight forward, but learning PS is not a bad way to import and learn scripting.
0
 
*** Hopeleonie ***IT ManagerCommented:
We created with CSV, but I think you can choose a format.
0
 
p_nutsCommented:
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..

new-ADUser

http://technet.microsoft.com/en-us/library/ee617253.aspx
0
 
Brian PiercePhotographerCommented:
There are lots of free tools available - why re-invent the wheal

eg http://ad-bulk-users.software.informer.com/
0
 
Manpreet SIngh KhatraSolutions Architect, Project LeadCommented:
Creating bulk Active Directory user and group accounts in PowerShell using Server 2008 R2 cmdlet
http://get-spscripts.com/2011/08/creating-bulk-active-directory-user-and.html

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

- Rancy
0
 
McKnifeCommented:
You can also use batch.
Fire the command dsadd user /? and see what's possible. Try using a for loop on your .csv/textfile.
0
 
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.
0
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.