Quickly Bulk-Create lots of AD Users

Quick blog showing a small script that can bulk create a lot of Active Directory users for you.

====
I’ve received this query multiple times over the last couple of months - need to provision lots of AD Users quickly for testing. Quick & dirty VB Script below that will create 1000s of users in an AD OU if you wish - though I’d share.

Copy and paste the below in to Notepad, save as VBS, and then modify accordingly. Job done.

=====
DIM oFSO,oShell

SET oFSO=CreateObject("scripting.filesystemobject")
SET oShell=CreateObject("wscript.shell")

DIM oUser, OU
SET OU=GetObject("LDAP://OU=TestUsers,dc=contoso,dc=local")

DIM NoUsers, UserName, count

count=0
NoUsers=4500

WHILE NOT Count=NoUsers
Count=Count+1

UserName="Test"&Count

SET oUser=OU.Create("USER","CN="&UserName)
oUser.Put "sAMAccountName",UserName
oUser.Put "sn","Surname"
oUser.Put "displayname",Username
oUser.Put "Description","Test User"
oUser.Put "mail",Username&"@Contoso.com"
oUser.SetInfo
oUser.SetPassword "FiddleSticks"
Wend

wscript.echo "Finished."

wscript.quit

=====

Bits in BOLD you need to edit:

SET OU=GetObject("LDAP://OU=TestUsers,dc=contoso,dc=local")
Change the OU path here to match your system - I.e. where you want the users creating.

NoUsers=4500
Set this to the number of users you want to create - in this case 4,500.

oUser.SetPassword "FiddleSticks"
Here, it’s important you set a password that will pass the security standards for the domain, otherwise the user won’t be created.

Anyways, quick and easy, just how I like it. The above will create however many accounts you need with an incremental name of TestX, where X is the increment.

blog comments powered by Disqus