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 of your lab mailbox needs.  Over the course of 2 days, I used this to create 1.2 million users.  You can see a few screen shots over at https://www.undocumented-features.com/2018/04/25/create-realistic-lab-users/ and check the entire blog series at https://www.undocumented-features.com/tag/create-labusers/.

UPDATES

PREVIOUS UPDATES

Parameters

This is where all of the magic happens.  I'll go over the parameters and what they do here.

Company

Specify value for company.  By default, it will use Contoso, Ltd. 

Count

Integer to specify number of users. Minimum 1, maximum 965,000,000 and change.

InflateMailboxes

Send test messages to mailboxes.

CalendarPermissions

Enable random assignment of calendar permissions.

MailboxAccessPermissions

Enable random assignmnt of mailbox permissions.

Domain

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).

OUPath

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.

UpnSuffix

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.

AddUPNSuffix

Add the UPN suffix specified in UpnSuffix to Active Directory if it does not exist.

ExchangeServer

Specify Exchange Server hostname.  The script will attempt to connect via Kerberos authentication; please use the NetBIOS name or a registered SPN.

CreateMailboxes

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.

CreateResourceMailboxes

Create standard resource mailboxes (Room, Equipment, Shared). Add room mailboxes
to location-specific Room Lists.

CreateGroups

Use this parameter to create and populate AD groups based on values in Locations and Roles.  It also creates nested groups (for example, if you have a role called "Manager," have users in Organizational Unit OU=Sales,OU=Washington,OU=Test Accounts,DC=domain,DC=com" that have "Manager" as their title, the script will create a group called "IT Manager - Washington", place the appropriate users in it, and then create an additional group called "IT Manager" and place the "IT Manager - Washington" group inside it.

TheWholeShebang

Automatically sets all mailbox and group creation options.

UserList

Specify a list of custom users via CSV.  Format: FirstName,MiddleName,LastName

 

PowerShell
Edit|Remove
<#     
.SYNOPSIS  
Bulk create realistic users for testlab. 
 
.PARAMETER AddUpnSuffix 
Add UPN suffix to Active Directory if it does not exit. 
 
.PARAMETER CalendarPermissions 
Enable assignment of calendar permissions. 
 
.PARAMETER Company 
Specify value for company. 
 
.PARAMETER Count 
Integer to specify number of users. Minimum 1, maximum 5,000,000. 
 
.PARAMETER CreateGroups 
Use this parameter to create and populate AD groups based on values in Locations  
and Roles. 
 
.PARAMETER CreateMailboxes 
Use this parameter to create mailboxes (as opposed to only creating AD users) 
 
.PARAMETER CreateResourceMailboxes 
Create standard resource mailboxes (Room, Equipment, Shared). Add room mailboxes 
to location-specific Room Lists. 
 
.PARAMETER Domain 
Specify domain suffix to use for UPN and PrimarySmtpAddress. 
 
.PARAMETER DomainController 
Specify static domain controller to be used for operations. 
 
.PARAMETER ExchangeServer 
Specify Exchange Server hostname. 
 
.PARAMETER InflateMailboxes 
Send test messages to mailboxes. 
 
.PARAMETER MailboxAccessPermissions 
Enable assignment of mailbox permissions. 
 
.PARAMETER NumberOfMessages 
Send 'n' test messages per user.  Default is 1. 
 
.PARAMETER OUPath 
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. 
 
.PARAMETER UpnSuffix 
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. 
 
.PARAMETER UserList 
Specify path to a userlist file to process before creating additional mailboxes. 
Userlist should be CSV format with headers: 
Firstname,MiddleName,LastName 
 
.PARAMETER Password 
Set password for new users or mailbox accounts.  Default password is P@ssw0rd123. 
 
.PARAMETER TheWholeShebang 
Automatically sets all mailbox and group creation options. 
 
.EXAMPLE 
.\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. 
 
.EXAMPLE 
.\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." 
 
.EXAMPLE 
.\Create-LabUsers.ps1 -Count 5000 -CreateGroups -AddUpnSuffix -UpnSuffix cohovineyardandwinery.com 
 
Create 5,000 AD user accounts in the default OU path. Create groups based on  
user locations and titles, and populate groups. 
 
.EXAMPLE 
.\Create-LabUsers.ps1 -Count 5000 -CreateGroups -MailboxAccessPermissions -CalendarPermissions -AddUpnSuffix -UpnSuffix cohovineyardandwinery.com 
 
Create 5,000 AD user accounts in the default OU path. Create groups based on  
user locations and titles, and populate groups.  Assign mailbox and calendar 
access permissions. 
 
.EXAMPLE 
.\Create-LabUsers.ps1 -Count 5000 -CreateGroups -AddUpnSuffix -UpnSuffix cohovineyardandwinery.com -InflateMailboxes 
 
Create 5,000 mailboxes in the default OU path. Create groups based on user 
locations and titles, and populate groups. Generate random mail content. 
 
.EXAMPLE 
.\Create-LabUsers.ps1 -ExchangeServer EXCHANGESRVR -TheWholeShebang 
Creates 10,000 user and resources mailboxes,along with associated groups,  
manager relationships, mailbox and calendar permissions, and executes mailbox  
content generation. 
 
.LINK 
https://undocumented-features.com/2018/04/25/create-realistic-lab-users/ 
 
.LINK 
https://aka.ms/CreateLabUsers 
 
.LINK 
https://undocumented-features.com/2018/05/29/update-to-create-labusers-tool/ 
 
.NOTES 
2018-11-13 
- Added random selection of names if custom user list is supplied but column 
  does not contain data 
- Added basic error checking to determine if custom user list header is correct 
2018-10-31 
- Resolved loop condition when running CreateResourceMailboxes mutliple times. 
- Added UserList parameter to allow custom user names. 
- Updated InflateMailboxes parameter to use Get-Recipient and include MailUser, 
  SharedMailbox, RemoteUserMailbox, and UserMailbox objects. 
2018-10-30 
- Added automatic detection of Exchange server. 
- Removed requirement for Exchange connecivity when creating groups 
- Added mailnickname attribute for creating both AD-only users and groups 
- Updated Room List creation 
- Added additional screen output during group creation and processing. 
- Added TheWholeShebang parameter. 
- Updated script to use Net.Mail.MailMessage instead of Send-MailMessage (Thanks  
  to Jonathan Christie) 
2018-07-30 
- Added #Requires -Version 4.0 
2018-06-28 
- Added resource mailbox provisioning. 
2018-06-27 
- Updated $MaxRecipients calculation to avoid error when using -Count parameter  
  with 1 user 
- Added "MiddleName" attribute 
2018-06-18 
- Updated default Password value to a more complex password to avoid substring  
  matches if the complex password policy is enabled 
- Updated sAMAccountName and userPrincipalName values to remove space characters,  
  since those caused provisioning errors 
2018-06-13     
- Updated CreateOU function logic. Moved previous logic to deprecated function. 
- Updated parameters to be more independent, so you can specify just creating  
  groups, just inflating mailboxes, etc. 
- Added -DomainController parameter to help with consistency in large lab  
  environments. 
2018-06-12 
- Added random binary attachments to InflateMailboxes parameter 
- Removed Count as a mandatory parameter; will allow just sending mail or  
  creating group membership assignments 
2018-06-05 
- Updated ambiguous -Member parameter. 
- Updated user count display. 
2018-05-29 
- Added random "GrantSendOnBehalfTo" rights 
- Added check for existing Exchange session 
- Added switch to deliver test messages to mailboxes 
2018-05-24 
- Added mailbox and calendar delegations. 
2018-04-26 
- Added group features. 
- Fixed manager assignment issue.  In some cases, managers were    being assigned  
  to users outside of the correct scope. 
2018-04-25 
- Initial release. 
#>