This blog is part of a series that shows example PowerShell code for those learning the language.
This time we’re using PowerShell to generate random full names using common first names and common last names. It basically combines a random first name with a random letter for middle initial and a random last name.
This example explores the use of loops, random numbers, string functions (split, padright) and conversion from [int] to [char].
| # # Creating common names # # Using the top first names published by the SSA at http://www.ssa.gov/OACT/babynames/ # And the top last names from http://en.wikipedia.org/wiki/List_of_most_common_surnames_in_North_America # $first = “Noah Sophia Liam Emma Jacob Olivia Mason Isabella William Ava Ethan Mia Michael Emily Alexander Abigail Jayden Madison Daniel Elizabeth”.Split(” “) Clear-Host 1..20 | foreach { |
One thought on “PowerShell Examples: Generating Random Names”