You want to create a large number of user objects, either for testing purposes or to initially populate Active Directory with your employee, customer, or student user accounts.

Using a command-line interface

The following example uses a for do loop in combination with dsadd to create 1,000 users under the marketing OU in the networkingpupil.com domain with usernames such as User1, User2, User3, etc. The password is set, but no other attributes are configured. You can modify the dsadd syntax to populate additional attributes, as well:

> for /F %i in (1,1,1000) do dsadd user cn=User%i,ou=marketing,dc=networkingpupil,dc=com
-pwd User%i

You can also use the ldifde utility to perform a bulk import of unique usernames. Create an .LDF file using the following syntax (separate multiple entries with a blank line in between):

dn: CN=Ali Hosseini, OU=Engineering, DC=networkingpupil, DC=com
changetype: add
cn: Ali Hosseini
objectClass: user
samAccountName: ahosseini

Once you've created the LDIF file containing your user records, import the file using the following command:

> ldifde -i -f -s 

Be aware that after -f type filename.ldf and after -s bring the servername
You may notice that the LDIF file does not specify the user's password; this attribute must be modified after the user object has been created.

You can also use admod to automate this task as follows. The code below will create 4,000 users named "TestUser_1", "TestUser_2", "TestUser_3":

> admod -sc adau:4000;MyPassword1!;cn=testuser,ou=testou,dc=networkingpupil,dc=com

Using VBScript
' This code creates a large number of users with incremented user names
' e.g. User1, User2, User3, ....
' ------ SCRIPT CONFIGURATION ------
intNumUsers = 1000 ' Number of users to create
strParentDN = "" ' e.g. ou=bulk,dc=emea,dc=adatum,dc=com
' ------ END CONFIGURATION --------
' Taken from ADS_USER_FLAG_ENUM
Const ADS_UF_NORMAL_ACCOUNT = 512
set objParent = GetObject("LDAP://" & strParentDN)
for i = 1 to intNumUsers
strUser = "User" & i
Set objUser = objParent.Create("user", "cn=" & strUser)
objUser.Put "sAMAccountName", strUser
objUser.SetPassword(strUser)
objUser.SetInfo
objUser.Put "userAccountControl", ADS_UF_NORMAL_ACCOUNT
objUser.SetInfo
WScript.Echo "Created " & strUser
next
WScript.Echo ""
WScript.Echo "Created " & intNumUsers & " users"

Using PowerShell
$parentDN = ""
$strPass = "MyPassword1"
For ($i = 1; $i -le 1000; $i++) {
$strUserName = "User" + $i
New-QADUser -name $strUserName -parentContainer $parentDN -UserPassword $strPass
}

Discussion

Using ADSI, PowerShell, and the command-line utilities, you can create hundreds and even thousands of users far more easily and quickly than you would be able to do through a graphical user interface. You can also modify the examples to pull real data from a data source, such as an employee database.

Using a command-line interface

The AdMod syntax makes use of the -adau shortcut, which will add X number of users with Y as their starting password, so that "-adau:4000;MyPassword1" will create 4,000 users with a starting password of "MyPassword1". If the starting password is not specified, a unique random complex password will be generated for each user.