Register for Semperis' Hybrid Identity Protection (HIP) Conference - June 30 - July 1 Register for Semperis' Hybrid Identity Protection (HIP) Conference - June 30 - July 1
Active Directory

Create Users for Testing Purposes

How can I create a large number of users for testing purposes?

If you want to create a large amount of test user accounts in your domain or local accounts on your workstation, you can do so in more than one way. On this page I’ll try to list a few of these methods.

If you happen to have some nice scripts that can do the same job in other methods (oh yes, there are other methods), please do send me an e-mail and I’ll upload it to this page .

Windows Server 2003 AD Note: Windows Server 2003 Active Directory is configured, by default, to request that any user that you create will have a password that is complex and with a minimum of 7 characters. Some methods described here (mainly method #3 and #4) cannot add the password attribute to a user account. In order for these methods to work in your test environment you must first disable the password requirement for the Windows Server 2003-based Domain. Read my Disable Password Requirements in Windows Server 2003 Domains article for more info.

Method #1: By using the NET USER command

NET USER is an old NT-related user manipulation command. I will not list all of it’s attributes here (you can find for yourself by going to the Help and Support site on your computer). I do not usually use the NET USER command in an AD environment, mostly due to the fact that it is not tailored for AD objects at all, but still, it can be used for our needs.

You can use the FOR and NET USER commands to accomplish the task in a “quick and dirty” way, without scripting or writing any code. For example, if you type from the command prompt:

FOR /L %i in (1,1,500) DO NET USER MyUser%i /ADD

This will result in creating 500 new users, named MyUser1, MyUser2, etc. You can, of course, customize the FOR command’s parameters. See the FOR command help for more options.

You can also set the user’s password (in this case – [email protected]) in the same manner:

FOR /L %i in (1,1,500) DO NET USER MyUser%i [email protected] /ADD

You can delete all those users by running the following command:

FOR /L %i in (1,1,500) DO NET USER MyUser%i /DELETE

Note: If run on a stand alone W2K Server, W2K PRO or on an XP machine, this script will create local users. If run on a DC it will create users in the USERS Container in the AD. However, doing so on a domain controller will not create fully AD-compatible users (as you can clearly see if you open one of these users and try to find the User Principal Name – UPN – field).

Note: If you’re using a W2K PRO or XP PRO computer that is connected to an Active Directory network and you wish to create local users on that computer – run the command above. However, if you want, from that computer, to create users in the Active Directory database on the DC, use this command instead:

FOR /L %i in (1,1,500) DO NET USER MyUser%i [email protected] /domain /ADD

To create users with pre-configured names (for example – a file with all your company’s usernames or a database with usernames) create a text file like this one:

daniel
moshe
yossy
gabi
ran
bijo
baruch
bibi

Name the file USERS.TXT and place it in a directory.

Now open a CMD in that directory and run the following command:

FOR /F %i in (users.txt) DO NET USER %i [email protected] /domain /ADD

This will create user accounts with the names found in the USERS.TXT file, all with the same password – [email protected] You don’t have to use the /domain switch unless you want to.

See the NET USER or NET USERS command help for more options.

Method #2: By using the DSADD USER command

DSADD USER is a command found in Windows Server 2003, and is specifically tailored for AD usage. Almost any user-related attribute can be set by using this command.

Note: The DSADD command is not just about adding users. Run DSADD /? in your CMD window and see for yourself.

For example, if you type from the command prompt:

dsadd user "cn=Test User,ou=Test OU,dc=dpetri,dc=net" -samid testuser -upn [email protected] -fn Test -ln User -display "Test User" -pwd [email protected] -disabled no

This will create one user called “Test User” with all the necessary information (and as I said earlier, more attributes can be easily configured in the same way).

Lamer Note: Note that you want to use the same syntax as above, you must first create the “Test OU” OU in you AD, and also change the DN of the domain to the name of YOUR domain.

However we would like to create many users for testing purposes. Therefore we can use the FOR command like we did before:

FOR /L %i in (1,1,500) DO dsadd user "cn=Test User%i,ou=Test OU,dc=dpetri,dc=net" -samid testuser%i -upn testuser%[email protected] -fn Test -ln User%i -display "Test User%i" -pwd [email protected] -disabled no

This script will create 500 users called Test User1, Test User2 and so on.

Like with NET USER, the DSADD USER command can be used along with a text or CSV file that contains a list of all the users that you want to build.

Create a text file like this one:

Blue,Kelly,bluek,04-6545645
Ben-Sachar,Ido,bensachari,03-7634545
Fluegel,Jay,fluegelj,03-9875765
Grande,Jon,grandej,02-6674534
Hankin,Alex,hankina,04-8856476
Jiang,George,jiangg,08-7636344
Kelly,Robert,kellyr,03-5568336
Kelly,Bob,kellyb,03-9567474
Li,Yuhong,liy,02-5462272
Moreland,Barbara,morelandb,04-88293922
Naik,Mandar,naikm,03-5531190
O'Donnell,Claire,odonnellc,03-5111930
Smith,John,smithj,03-8102201

Name the file USERS.TXT and place it in a directory.

Now open a CMD in that directory and run the following command:

for /F "eol=; tokens=1,2,* delims=," %%i in (users.txt) do dsadd user "cn=%%j %%i,ou=Test OU,dc=dpetri,dc=net" -samid %%k -upn %%[email protected] -fn %%j -ln %%i -display "%%j %%i" -pwd [email protected] -disabled yes

This will create user accounts with the names found in the USERS.TXT file.

Imagine the power of such a script!

Method #3: By using the CSVDE command

CSVDE is a command that can be used to import and export objects to and from the AD into a CSV-formatted file. A CSV (Comma Separated Value) file is a file easily readable in Excel.

I will not go to length into this powerful command, but I will show you some basic samples of how to import a large number of users into your AD. Of course, as with the DSADD command, CSVDE can do more than just import users. Consult your help file for more info.

For example, lets say I would like to create a number of very simple users. Just the necessary information, nothing more.

Create a text file like this one:

dn,sAMAccountName,userPrincipalName,userAccountControl,objectClass
"CN=Amie Baldwin,OU=Test OU,DC=dpetri,DC=net",amieb,[email protected],512,user
"CN=Scott Culp,OU=Test OU,DC=dpetri,DC=net",scottc,[email protected],512,user
"CN=Derek Graham,OU=Test OU,DC=dpetri,DC=net",derekg,[email protected],512,user
"CN=Stephanie Bourne,OU=Test OU,DC=dpetri,DC=net",stephanieb,[email protected],512,user
"CN=Matthew Dunn,OU=Test OU,DC=dpetri,DC=net",matthewd,[email protected],512,user

Name the file USERS.CSV and place it in a directory.

Open a CMD in that directory and run the following command:

csvde -i -f users.csv

(use your own path)

This will create 5 user accounts with the names found in the USERS.CSV file.

Note: Note that CSVDE, unlike DSADD USER, cannot import passwords into the AD. For that reason, unless you specify the userAccountControl attribute as 512, the users that will be imported will be disabled by default. Also remember that you must Disable Password Requirements in Windows Server 2003 Domains in order for this command to work in Windows Server 2003-based domains.

Now lets say I would like to create the same users but this time with associated mailboxes stored on my Exchange server called SERVER100.

Create a text file like this one (select all and just copy):

DN,objectClass,name,homeMDB,cn,displayName,mail,givenName,proxyAddresses,sAMAccountName,sn,userAccountControl,userPrincipalName,homeMTA,msExchHomeServerName,mailNickname,countryCode,c,l,homePhone,mobile,telephoneNumber,co,wWWHomePage
"CN=kuku levi,OU=Test OU,DC=dpetri,DC=net",user,kuku levi,"CN=Mailbox Store (SERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",kuku levi,kuku levi,[email protected],kuku,SMTP:[email protected];X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi';g=kuku';,kukul,levi,512,[email protected],"CN=Microsoft MTA,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVER100,kukul,376,IL,Tel-Aviv,03-4534545,051-345345,03-4534545,ISRAEL,petri.com
"CN=momo levi,OU=Test OU,DC=dpetri,DC=net",user,momo levi,"CN=Mailbox Store (SERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",momo levi,momo levi,[email protected],momo,SMTP:[email protected];X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi';g=momo';,momol,levi,512,[email protected],"CN=Microsoft MTA,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVER100,momol,376,IL,Tel-Aviv,03-9879878,053-878345,03-9879878,ISRAEL,www.msn.co.il
"CN=jojo levi,OU=Test OU,DC=dpetri,DC=net",user,jojo levi,"CN=Mailbox Store (SERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",jojo levi,jojo levi,[email protected],jojo,SMTP:[email protected];X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi';g=jojo';,jojol,levi,512,[email protected],"CN=Microsoft MTA,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVER100,jojol,376,IL,Tel-Aviv,03-2424478,053-654654,03-2424878,ISRAEL,www.cnn.com
"CN=bubu levi,OU=Test OU,DC=dpetri,DC=net",user,bubu levi,"CN=Mailbox Store (SERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",bubu levi,bubu levi,[email protected],bubu,SMTP:[email protected];X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi';g=bubu';,bubul,levi,512,[email protected],"CN=Microsoft MTA,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVER100,bubul,376,IL,Tel-Aviv,03-8768767,053-456658,03-8768767,ISRAEL,www.cnn.com
"CN=dudu levi,OU=Test OU,DC=dpetri,DC=net",user,dudu levi,"CN=Mailbox Store (SERVER100),CN=First Storage Group,CN=InformationStore,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",dudu levi,dudu levi,[email protected],dudu,SMTP:[email protected];X400:c=us';a= ';p=Dpetri';o=Exchange';s=levi';g=dudu';,dudul,levi,512,[email protected],"CN=Microsoft MTA,CN=SERVER100,CN=Servers,CN=First Administrative Group,CN=Administrative Groups,CN=Dpetri,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=dpetri,DC=net",/o=Dpetri/ou=First Administrative Group/cn=Configuration/cn=Servers/cn=SERVER100,dudul,376,IL,Tel-Aviv,03-5645446,051-978879,03-5645446,ISRAEL,www.disney.com

Note: The text might look a bit garbled, but if you copy and paste inside a new text file you’ll see it fine. Excel will also help you with editing the file.

Lamer Note: This might be a good point to remind you to USE YOUR OWN NAMES!!!

Name the file USERS.CSV and place it in a directory.

Open a CMD in that directory and run the following command:

csvde -i -f users.csv

(use your own path)

This will create 5 user accounts with the names found in the USERS.CSV file, alongside with some nice attributes for each user.

Method #4: By using the LDIFDE command

Like CSVDE, LDIFDE is a command that can be used to import and export objects to and from the AD into a LDIF-formatted file. A LDIF (LDAP Data Interchange Format) file is a file easily readable in any text editor, however it is not readable in programs like Excel. The major difference between CSVDE and LDIFDE (besides the file format) is the fact that LDIFDE can be used to edit and delete existing AD objects (not just users), while CSVDE can only import and export objects.

Like in CSVDE, I will not go to length into this powerful command, but I will show you some basic samples of how to import a large number of users into your AD. Of course, as with the DSADD command, LDIFDE can do more than just import users. Consult your help file for more info. Here too, remember to Disable Password Requirements in Windows Server 2003 Domains in order for this command to work in Windows Server 2003-based domains.

For example, just like with the CSVDE command, lets say I would like to create a number of very simple users. Just the necessary information, nothing more.

Create a text file like this one:

dn: CN=Amie Baldwin,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Amie Baldwin
objectClass: user
name: Amie Baldwin
sAMAccountName: amieb
telephoneNumber: 555-1234
userAccountControl: 514
userPrincipalName: [email protected]

dn: CN=Scott Culp,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Scott Culp
department: Accounting
objectClass: user
name: Scott Culp
sAMAccountName: scottc
telephoneNumber: 555-1236
userAccountControl: 512
userPrincipalName: [email protected]

dn: CN=Derek Graham,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Derek Graham
department: Accounting
objectClass: user
name: Derek Graham
sAMAccountName: derekg
telephoneNumber: 555-1239
userAccountControl: 512
userPrincipalName: [email protected]

dn: CN=Stephanie Bourne,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Stephanie Bourne
department: Accounting
objectClass: user
name: Stephanie Bourne
sAMAccountName: stephanieb
telephoneNumber: 555-1239
userAccountControl: 512
userPrincipalName: [email protected]

dn: CN=Matthew Dunn,OU=Test OU,DC=dpetri,DC=net
changetype: add
cn: Matthew Dunn
department: Accounting
objectClass: user
name: Matthew Dunn
sAMAccountName: matthewd
telephoneNumber: 555-1230
userAccountControl: 512
userPrincipalName: [email protected]

Note that unlike the CSV-formatted file, the LDIF file is quite easy to understand and edit in Notepad. However, you may find it easier to edit a large number of users via Excel than through Notepad, that’s why the CSV-formatted file will still be easier to manipulate than the LDIF-formatted file.

Name the file USERS.LDF and place it in a directory.

Open a CMD in that directory and run the following command:

ldifde -i -f users.ldf

(use your own path)

This will create 5 user accounts with the names found in the USERS.LDF file.

Since the only difference between the CSVDE and LDIFDE commands is the file format I will stop here. Remember that you can add almost any user-configurable attribute by using these commands. Test them on your own, and if you come up with a truly amazing result please share it with us .

Links

Step-by-Step Guide to Bulk Import and Export to Active Directory

Importing and exporting directory information

Using LDIFDE to Import and Export Directory Objects to Active Directory – 237677

How to Use Csvde.exe to Import Contacts into Active Directory – 300409

Related Topics:

BECOME A PETRI MEMBER:

Don't have a login but want to join the conversation? Sign up for a Petri Account

Register
Comments (13)

13 responses to “Create Users for Testing Purposes”

  1. Just do I(nformation)T(echnology) : Load Testen van Sharepoint met VSTS 2008 en VSTT Load Agents – Deel 2

    [...] providers wilt maken, zal je ook test users moeten aanmaken. Een voorbeeld is te vinden op : https://petri.com/create_users_for_testing_purposes.htm Nu hoef je niet voor elke virtual user een testuser aan te maken, maar voor elke 25 users zou ik [...]
  2. Load Testen van Sharepoint met VSTS 2008 en VSTT Load Agents – Deel 2 - Het Wat?, Hoe? en Waarom? van een IT-er..

    [...] providers wilt maken, zal je ook test users moeten aanmaken. Een voorbeeld is te vinden op : https://petri.com/create_users_for_testing_purposes.htm Nu hoef je niet voor elke virtual user een testuser aan te maken, maar voor elke 25 users zou ik [...]
  3. درخواست راهنمایی در مورد دستورات CSVDE برای ساخت User - Persian Networks

    [...] خوبی زده است ( با استفاده از net user , dsadd , csvde , LDIFDE ) Create Users for Testing Purposes خلاصه موضوع آبجکتهای مورد نظر را مانند کد های زیر در [...]
  4. import کردن فایل csv در activedirectory - Persian Networks

    [...] منتقل کنم ولی نه با پسوردهای خودشان با پسوردهای دیگر . Create Users for Testing Purposes یکی از دوستان به من گفت :(براي اين كار وارد Excel شويد. در [...]
  5. Generating Dummy Profiles for your Shared Service Provider « Thomas Daly's SharePoint Blog

    [...]  This will generate about 500 dummy users. Please read more about that here [...]
  6. Import Users via Excel

    [...] page describes the various methods and sytax to use: Create Users for Testing Purposes Reply With Quote [...]
  7. Quickly Create Test Users on your Domain Controller | code.commongroove.com

    [...] https://petri.com/create_users_for_testing_purposes.htm [...]
  8. cmdline » Blog Archive » Populating Your Virtual Victim Domain

    [...] https://petri.com/create_users_for_testing_purposes.htm [...]
  9. Dydaktyka Władysław Czaja

    [...] https://petri.com/create_users_for_testing_purposes.htm [...]
  10. Import fictional active directory users

    [...] Ta-daaa!: Create Users for Testing Purposes Reply With [...]
  11. Vidat kukul | Kemchotv

    [...] Create Users for Testing PurposesJan 7, 2009… Disable UAC in Windows Vista · Install Active Directory on Windows …. levi, [email protected],kuku,SMTP:[email protected];X400:c=us’;a= ‘ … [...]
  12. Server2003 dsadd | Alldigiphoto

    [...] Create Users for Testing PurposesJan 7, 2009 … DSADD USER is a command found in Windows Server 2003, and is specifically tailored for AD usage. Almost any user-related attribute can be … [...]
  13. Figormonde | Pearltrees

    [...] Create Users for Testing Purposes Easily bulk add users? Dont use DSADD, CSVDE or LDIFDE! Microsoft has a couple of tool sets available to add bulk users to active directory: DSADD, CSVDE, and LDIFDE. I’m quite sure you’ll be able to find a couple of examples on the web of how to use these tools, but it all comes down to making a script, or spending a couple of hours copy-pasting information. But in the real world, I want to easily add users to active directory. Last week I had to add about 160 users to a domain, and I received a spreadsheet with all the information (names, usernames etc.) from HR. Easily bulk add users? Dont use DSADD, CSVDE or LDIFDE! | tomfloor.wordpress.com How can I quickly create 100 users on my Active Directory for testing purposes The Active Directory (AD) module may be installed as part of the RSAT feature on a Windows 7 / 2008 R2 server (or by default, with the AD DS or AD LDS server roles.) Once installed, load the Active Directory module with Import-Module ActiveDirectory or click Start, Administrative Tools, Active Directory Module for Windows PowerShell. Disable-adAccount Disable an Active Directory account. Enable-adAccount Enable an Active Directory account. Active Directory PowerShell cmdlets Add A Bulk Of Users In Active Directory Using Script Today I'm going to talk about interacting with CSV files using powershell. You may use CSV files to store values temporarily for a script, or you may be creating user accounts in Active Directory. I'll be going over the process of how to read the file and declare variables for the headers. The root of the whole process is importing a CSV file you've created. The command to do this is: Powershell: Working with CSV Files Add A Bulk Of Users In Active Directory Using Script dsadd from excel - Google Blogs We had a requirement of creating bulk users in Active directory for Test users. Initially i thought of wrtting .NET code which will communicate to LDAP and creates the users. but i was not aware of that it can be done very-2 quickly using the Powershell with 3-4 line of scripts. we had a csv file which had all the users with AD information in it. The Format of that csv is some thing like the below one: Please change the {Domain Name} with your Environment Domain name. Below is powershell script which will create users in Active directory, please ensure to run this powershell script in "Active Directory Module For Windows PowerShell".UserCreationfile.csv is a csv filename which has all users information. So I had to add about 70 user accounts to Active Directory in preparation for a new call center. Sounds like boring, tedious work if you ask me. Well, it would be without the magic of dsadd.exe, a command in Windows 2003 command line that allows you to create Active Directory objects, such as users, computers, groups, contacts, and OUs. My focus here is on adding multiple user accounts. Focusing on my needs, I wanted to add the user, set the display name, set a password, set a description, set the office, their title and department, and their logon script while forcing a password change and the ability to change the password. I also wanted these accounts to start disabled since it might be a week or two before the users are ready for them. Using DSADD.exe to Bulk Create Users in Active Directory apps [...]

Leave a Reply

Register for the Hybrid Identity Protection (HIP) Europe Conference!

Hybrid Identity Protection (HIP) Europe 2021 - Virtual Conference

Mobile workforces, cloud applications, and digitalization are changing every aspect of the modern enterprise. And with radical transformation come new business risks. Hybrid Identity Protection (HIP) is the premier educational forum for identity-centric practitioners. At the inaugural HIP Europe, join your local IAM experts and Microsoft MVPs to learn all the latest from the Hybrid Identity world.