Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Adding Bulk Users in AD

Posted on 2012-08-11
Medium Priority
1 Endorsement
Last Modified: 2012-08-14
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.

Question by:Earl28
  • 3
  • 3
  • 2
  • +6
LVL 13

Expert Comment

ID: 38284412
LVL 13

Expert Comment

ID: 38284447
What format do you have the users details in?
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 38284459
CSV, and its just FirstName,LastName.

Author Comment

ID: 38284462
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.

Assisted Solution

by:Brent Challis
Brent Challis earned 400 total points
ID: 38284478
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
LVL 24

Expert Comment

ID: 38284680
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.
LVL 19

Expert Comment

by:*** Hopeleonie ***
ID: 38284878
We created with CSV, but I think you can choose a format.
LVL 13

Expert Comment

ID: 38284907
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..


LVL 70

Expert Comment

ID: 38285083
There are lots of free tools available - why re-invent the wheal

eg http://ad-bulk-users.software.informer.com/
LVL 52

Expert Comment

by:Manpreet SIngh Khatra
ID: 38285719
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
LVL 58

Expert Comment

ID: 38288938
You can also use batch.
Fire the command dsadd user /? and see what's possible. Try using a for loop on your .csv/textfile.

Accepted Solution

Sergey Kolesnik earned 1600 total points
ID: 38289564

Author Closing Comment

ID: 38290419
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.

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
The article explains the process to deploy a Self-Service password reset portal I developed a few years ago. Hopefully, it will prove useful to someone.  Any comments, bug reports etc. are welcome...
To efficiently enable the rotation of USB drives for backups, storage pools need to be created. This way no matter which USB drive is installed, the backups will successfully write without any administrative intervention. Multiple USB devices need t…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

572 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question