Getting Real With Fake User Data

I’ve spent a decent chunk of time setting up my VM test lab, as I’m sure many others have. In my lab I have AD, Exchange 2010, Lync 2010 & 2013, TMG, an Asterisk based PBX, and a couple client VMs running Windows 7 with Office and the Lync client installed. It’s a great learning exercise to get everything setup and be able to play around with the configuration options. I’ve actually lost count at how many times I’ve wiped and rebuilt my lab to test different scenarios. I like to simplify the setup as much as possible to reduce the time needed for setup.

One necessity I’ve run into with my lab is test user accounts. Originally like a lot of other people out there I started with just a few accounts with names like TestUser1 or Exch2010UserB. Don’t get me wrong, it works just fine for testing; but I wanted more. So what started with me generating a list of 50 random names, to name my test user accounts, eventually grew into what I’m posting today. Read further to learn about New-AdTestUsers.

This script is packaged a little differently than the other scripts I have previously posted, this one is in a zip file as opposed to just being the script for download. When you extract the zip file you’ll find the New-AdTestUsers.ps1 script, a Users.csv file containing the user data, and a folder called photos. Let’s start by looking at the user data.

I have included data for 50 test user accounts that contain the following information GivenName, SurName, SAMAccountName, DisplayName, ADPhoto, ipPhone, Title, Manager, Department, Office, EmployeeID, OfficePhone, StreetAddress, City, State, Country, and PostalCode. I have defined three offices for the users (US, UK, and Brazil) and included the relevant associated information like address and e.164 phone numbers. All addresses and phone number are FAKE but match the correct format for their location. Users have also be assigned Employee ID numbers, job titles, departments, and even managers.

The user creation and Lync enablement parts of the script can be run from any machine that has the PowerShell AD tools installed, however I run it from my Exchange box in the Exchange Management Shell because that’s only place where the email and distribution group section works. I would recommend you do the same.

The command to create the users is “New-AdTestUsers.ps1 -ADEnable $True -ImportPhotos $True” you can leave off the “-ImportPhotos $True” option if you don’t want or need the contact photos imported into AD. The other option with the command is -OU “OU=Test Users,DC=domain,DC=com” which will place the new user accounts in the OU you specify. Be aware that whatever OU you specify will need to be created manually first. If you do not specify an OU, the accounts will be created in the default users container.

To mail enable the users and create the distribution groups you will need to run the following command “New-AdTestUsers.ps1 -MailEnable $True”. You can also use the -OU option here to specify where the distribution groups should be placed. Again, if you don’t specify an OU it will default to the default users container. The script does not assign any mailbox policies or email addresses and will home the users on the Exchange server where the script is run.

Distribution groups are created based upon three things. The first being Department, then Office, and finally a Managers distribution group. All distribution groups are created based upon attributes listed in the CSV so if you add or change Office names or Departments it will be reflected in the final group memberships.

The last option is to enable the users for Lync which also enables them for Enterprise Voice and sets their LineURI based upon their Office phone number and ipPhone extension. The command to do this is  “New-AdTestUsers.ps1 -LyncEnable $True”. You will need to change a couple options within the script before the Lync commands will work. Specifically you will need to set the Lync pool or server name where you want the users homed as well as their SIP domain.

Also consider the Default Password setting at the beginning of the script, which as you can guess sets the default password for the newly created test user accounts. This gets set during the first ADEnable step so make sure you set it to what you need before you start. Just in case you forget, I have the default set to “Sandwich1”.

Regarding the included photos, I got all of these from searches of Creative Commons licensed images that did not have attribution required and allowed for redistribution. If you happen to notice one in there that shouldn’t be, please let me know and I will remove/replace it.

As with all of the stuff I post, PLEASE PLEASE PLEASE test and verify before you deploy this. I’m not responsible for any and all problems that may arise from using this in a testing or production environment. The script download link can be found below.


Download New-ADTestUsers.zip


Creative Commons License
New-ADTestUsers.ps1 by Christopher Cook is licensed under a Creative Commons Attribution 3.0 Unported License.

Leave a Reply

Your email address will not be published. Required fields are marked *