I’m not a very creative person when it comes to making up fake names.   Thus when I need to “invent some users” for a Demo environment I usually end up with “John Smith”, “Mary Smith”, “Joe Bloe” and I start running out of ideas pretty darn quick.

Tomorrow I’m doing a small presentation at our User Group on Powershell and I wanted to actually have a REAL looking Active Directory.  

The populating part is easy.  But I wanted a REALLY good list of names.  And I wanted to be able to add to that list without TRYING.

Thus, Powershell

I made two simple text files.   Firstname.csv and Lastname.csv

First row in “Firstname.csv” was called “Firstname” and the first row in “Lastname.csv” was called “Lastname” (See! I told you I wasn’t THAT kind of creative!)

In the “Firstname.csv” text file was a list of (Gee can you guess?) Firstnames.  I found a few lists online and used those for samples.  Mine were French!

And (drum roll please) “Lastname.csv” was a list of last names.

Ahem.  Here’s the fun part

A nice little script that pulls that data together (regardless of size) and produces a brand NEW CSV file called “DomainUsers.CSV” which is perfect for making whatever you want.  All your fake John, Joe, Mary, Frank Smiths ET AL!

And all of my files are in a folder called “C:Powershell Scripts’”

———– RandomUsers.PS1 ———————

# Import list of Last names from Simple Text file

$lastname=import-csv ‘C:Powershell Scriptslastname.csv’

# Import list of First names Simple Text file

$firstname=import-csv ‘C:Powershell Scriptsfirstname.csv’

# How many names to generate


# the Header for our new CSV file


# Create a file called “DomainUsers.csv”

# By the way, the script is DEAD simple.  It doesn’t check for the existence

# of the file before hand.   So play with it how you want 🙂

Add-content -path ‘C:Powershell ScriptsDomainUsers.csv’ -value $firstline

# Go through and Generate some names

foreach ( $namecounter in 1..$totalnames )

    # Pick a random first and Last name

    $lastnamenumber=(get-random -min 0 -max (($lastname.Count)-1))
    $firstnamenumber=(get-random -min 0 -max (($firstname.Count)-1))


    # Echo the New name to the Screen

    write-host $fakename

    # and write to the File

    add-content -path ‘C:Powershell ScriptsDomainUsers.csv’ -value $fakename

—————— RandomUsers.ps1 ——————–

And that’s it!

All that baby does is generate a list of names from random First and Random Last names which I can now use to import into Demo Active Directories or other environments as sample data!

Save your Brain!  Use Powershell!

The Energized Tech