I needed to create some users for my Active Directory domain I created to use in the book “Windows PowerShell Bible” for the Exchange Management chapter.
I could have done something simple like:
This would have created 120 users in the Users ou on my domain, but they would have all been “BookUser” users – where’s the variety in that?
I wanted random users, to more closely mimic a real domain. Searching for a random name generator led me to http://www.kleimo.com/random/name.cfm. I chose to create 30 random names for both sexes, and ran the “Generate Random Names”
I copied the 30 resultant names to a notepad, and ran the page two more times, giving me 120 names.
Of those, a few were single names, which I eliminated.
I then replaced each space with a comma, saved the file as a .csv, and opened it in Excel.
Using Excel, I created a user name consisting of the first initial of the first name, and the whole last name.
I then added a 4th column, for the password.
Finally, I added column headers: First, Last, Login, and Password. Once again, I saved the file.
Now, I’m ready for PowerShell:
There you go… 14 lines, and a little work, and I have over 100 users on my domain.
Edited as I realized I needed the samaccountname and userprincipalname, and to follow Doug’s suggestion,