Creating Random Demo Users in Active Directory using PowerShell

It seems like I’m always building demo environments, whether it be for personal demo environments for speaking engagements or developer VMs for project work. One constant (other than installing SharePoint, SQL, Visual Studio, SharePoint Designer, etc.) is that I’m always trying to come up with names for users in Active Directory so I can run the User Profile Sync and show some data.

After doing this about 1,000,000 times – I decided to use something I learned at PowerShell Saturday over the weekend, the AD Cmdlets! There is a New-ADUser cmdlet that provisions an Active Directory user.

Once I knew that, I thought “I bet I could provide an array of names and use Get-Random to create users with random first names and last names.” That’s exactly what I set out to do, and I’ve got it working – it essentially uses a do while loop to run until the number of users specified is reached. I’ve looked up popular names to create a simple array of a few dozen first names and 20 or so last names. Get-Random simply creates random names from these arrays. Without further ado, here’s the function!