I have been spending time lately working on simulating AD migrations and investigating user experience. The general goal is to find and purposely cause issues during the migration and then create audits to find and mitigate the pain points.

In order to accomplish that I needed some real looking users in my environment. So I went ahead and created a script that utilizes the API found over at https://www.randomuser.me

A neat little API you can generate fake user information in blocks of up to 5,000. The full documentation can be found here.

find_ad_id is a function I wrote for my personal profile a while ago. Really pretty straightforward but I find it very useful. It takes a first and last name as an input and then strips all spaces out of the name. The next step is to take the firstname and break it up into initials. It tries combining the first name into the last name looking for an un-used Samaccountname value in AD.

For example:
John Doe
Jdoe is attempted, then jodoe until either a free sam account is found or an error is logged.

Generate creates an 11 – 19 character password for each user. It first goes through and 8 – 16 iterations of randomly chosen Lowercase, Uppercase, Numbers or Symbols. Then it purposely appends a Symbol, A capital letter and a number. This of course limits what the end characters will be with the generator, but it does make sure the password always meets Active directory Minimal password requirements

The rest of the script simply handles data from the API, creates the user and logs the password.
If you have any questions feel free to leave a comment.