Update: I’ve added a shortlink for this tool: http://aka.ms/createlabusers.
In testing out some of my other tools over the last few weeks, I’ve found it necessary to create a some test users. A lot of test users. Not a normal “a lot,” either. I needed hundreds of thousands at a minimum, a million if possible, as fully fleshed-out can be. I needed some with Exchange mailboxes, some without. I wanted locations, departments, job roles, and org charts.
I’ve found several scripts around the internet that purport to do parts of this, and can (to some extent), but nothing that gets close to the level of complexity that I wanted to entertain. And, you frequently had to supply your own names, addresses, and so forth. Too much stuff to keep track of and copy around as I needed.
So, I wrote a tool.
It’s got enough possible combinations to get you to nearly 1 billion user accounts. Yes, that’s billion with a b. I’ve got some plans to features to add to it, but for now, this should meet
all most of your lab mailbox needs. Over the course of 2 days, I used this to create 1.2 million users. At that point, I figured it wasn’t going to break.
Oh, and it also can create and populate nested groups.
This is where all of the magic happens. I’ll go over the parameters and what they do here.
Add the UPN suffix specified in UpnSuffix to Active Directory if it does not exist. Yeah, I know. Now I’m just showing off.
Specify value for company. By default, it will use Contoso, Ltd.
Integer to specify number of users. Minimum 1, maximum 965,000,000 and change.
Yes, I had to come back and add this feature, since it seemed like a glaring omission. Using the Locations and Roles, the CreateGroups parameter will create groups containing both users and roll-up nested groups. It further adds realism to the environment.
Use this switch parameter to create mailboxes (as opposed to only creating AD users). It will bark at you if you specify this without specifying an Exchange server.
Specify domain suffix to use for UPN and PrimarySmtpAddress. The domain doesn’t have to be part of the forest UPN suffixes or an Exchange accepted domain. However, if it’s not an Exchange Accepted domain and you create mailboxes, at some point, when the address book is updated, the default address policy may interfere with it (unless you flag the mailboxes to not inherit the email address policy).
Specify Exchange Server hostname. The script will attempt to connect via Kerberos authentication; please use the NetBIOS name or a registered SPN.
Specify OU path under which to create users. If it does not exist, the path will be created. The syntax will be checked for validity; if the path specified
cannot be created (such as incorrect forest), the script will exit. By default, the script will create a test OU at OU=”Test Accounts,DC=<domain>,DC=com,” and then a series of OUs underneath it that map to the state and department variables.
Value for UPN suffix. Default value is forest DnsDomainName. If this value is specified, it will be used in place of the current DomainName value.
Now, on to some examples.
.\Create-LabUsers.ps1 -CreateMailboxes -ExchangeServer Exchange1 -AddUpnSuffix -UpnSuffix contoso.com -Count 5000
Create 5,000 mailboxes using Exchange server Exchange1. Add the UPN Suffix contoso.com to the forest.
.\Create-LabUsers.ps1 -UpnSuffix fabrikam.com -Count 5000 -Company "Fabrikam, Inc." -OUPath "OU=Fabrikam Users,DC=domain,DC=com"
Create 5,000 AD user accounts in a structure starting at OU=Fabrikam Users,DC=domain,DC=com.”
One of the fun aspects was figuring out how to provision groups in a way that would make sense. As I mentioned in the parameter description, I ended up using the user job titles in conjunction with their state location to create groups. In this example, you can see that the script has created a number of groups and relationships. The “Consulting Manager – New York” group was created because there are users in the OU=Consulting,OU=New York,OU=Test Accounts container that have the job title “Manager.” The group “Consulting Manager” was created to hold all of the “Consulting Manager – <state>” groups. And, as you can also see, users with the title “Manager” are eligible to have direct reports.
If a user is created in an OU that already has someone with a Manager title, they will get assigned that user as a manager.
As always, let me know what works and what doesn’t for you guys. Until then, bulk up in a steroid-free way using this script over at https://gallery.technet.microsoft.com/Create-Realistic-Lab-Users-b756fedf.