Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to create 100 users just for test purposes of my Exchange Server.

Is there a way to batch do this using random names, etc?

share|improve this question
What version of Exchange? – Ben Pilbrow Dec 6 '10 at 13:23
Exchange Server 2003. – Sergio Tapia Dec 6 '10 at 13:29
up vote 4 down vote accepted

Here is a script that I made to use dsadd. I have a one line batch file that imports all of my new users every year:

(There might be a better way to display this, but I haven't had coffee yet.)

for /F "tokens=1,2,3,4 delims=," %%i in (freshmen09.csv) do dsadd user "cn=%%j %%i,ou=2013,ou=students,dc=[domain],dc=org" -samid %%k -pwd "%%l" -upn %%k@[domain].org -fn "%%j" -ln "%%i" -display "%%j %%i" -memberof "cn=GL 2013,ou=2013,ou=students,dc=[domain],dc=org" -disabled no -mustchpwd yes -hmdrv U: -hmdir "\\[network home directory]\2013\%%k"

This take 4 columns from a CSV file: Last Name, First Name, Username, Password

  • It creates a user for each row in the file,
  • Puts them into the desired OU,
  • Sets the password,
  • Adds them as a member of a group,
  • Enforces that the password must be changed when the user first logs in,
  • Sets the home directory to the appropriate place on our network share.

I have tried to get this to create email addresses automatically, but I have had inconsistent results. It is easy enough to just select all the users at once in Active Directory Users and Computers and setup Exchange Mailbox from there. Very simple, and much easier than figuring that part out with DSADD.

DSADD has many other parameters as well. You can basically make it set any user properties that you want. Simple, easy, and fast.

One failure: Username collisions need to be handled manually. We occasionally have students with names like James Smith and Jonathon Smith. If you have a system to prevent collisions ahead of time, perfect. If not, I recommend redirecting the output of the bat file to a text file and just search for "Fail" in the results.

freshmen09.bat > freshmen09_output.txt

(There is likely a much better way to do this part...)

share|improve this answer

On the command prompt, look at "dsadd":

or "net user":

You can use excel or notepad etc to prepare a list of commands to paste into a command prompt, or make a batch file.

share|improve this answer
It says that applies to Windows Server 2008. Will this work in Windows Server 2003, what I'm using? – Sergio Tapia Dec 6 '10 at 13:31
My bad linking! Yes it will :) – simon Dec 6 '10 at 13:42

If you have a Windows Server 2008 R2 Domain Controller available, you can run the following PowerShell script to create some dummy users. You'll still have to use Active Directory Users and Computers to mailbox enable these users, but you can select all the users and do it in bulk.

You can change the number of users created, and the password on the accounts as well. Note that the password must comply with any password requirements (complexity, length etc.) in effect.

Save as NewUsers.ps1 and run from the Active Directory Module for Windows PowerShell.

[1..100] | % { New-ADUser "User$_" -AccountPassword (ConvertTo-SecureString -AsPlainText -Force -String "P#$$w0rd") -Enabled $True }
share|improve this answer

Check the script here:

Make sure your internal domain is CONTOSO.COM, or else change the script. You will have to create mailboxes for all the users afterwards, but that is pretty easy to do in bulk.

share|improve this answer

Or we can use this command dsadd user here is one article which is talking about who to create user and folders.

set FirstName=Graice
set LastName=tsai
set LogonName=graice
set pass=welcome
dsadd user ”CN=%LogonName%, ou=FTPUsers, dc=yourDCname,dc=com” -pwd %pass% -pwdneverexpires yes -samid %LogonName% -upn %LogonName% -ln %LastName% -fn %FirstName%
dsmod user ”CN=%LogonName%, ou=FTPUsers, dc=yourDCname,dc=com” -disabled no
dsmod group ”CN=FTP Users, ou=FTPUsers, dc=yourDCname,dc=com” -addmbr ”cn=%LogonName%, ou=FTPUsers, DC=yourDCname, DC=com”
share|improve this answer

A colleague and myself came up with a useful script which generates 5000 users to test the ldap user limits of our java client. It was run on a Windows Server 2008 server using the Administrator account.

Simply save the following to a run.cmd file, adjust the domain name and OU, and run it using a command prompt:

@echo off
set FirstName=test
set LastName=user
set LogonName=testuser_new
set pass=Welcome_1234
setlocal enableextensions enabledelayedexpansion

FOR /L %%A IN (1,1,5000) DO (

    echo %LogonName%_%%A

    dsadd user "CN=%LogonName%_%%A, CN=Users, dc=fist,dc=com" -pwd %pass% -pwdneverexpires yes -samid %LogonName%_%%A -upn %LogonName%_%%A -ln %LastName% -fn %FirstName%
    dsmod user "CN=%LogonName%_%%A, CN=Users, dc=fist,dc=com" -disabled no



You can create more users just by adjusting the limit in the FOR loop.

share|improve this answer

This could help you in an easy way:

This is better if you want to have specific names for each user, different than user1, user2, etc.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.