A PowerShell version 2.0 script function to spell one or more strings, such as passwords, phonetically. If requested, the function determines if the strings meet complexity requirements. This allows any code that generates passwords to include more characters.

There are many scripts that generate random passwords. To meet the requirements of password complexity they allow lower and upper case letters, digits, and symbols. However, most restrict the array of possible characters to avoid confusion. For example, some do not allow the upper case "D" and "O", or the digit "0", because they can be confused visually. Often the digit "1", the lower case "l", and the upper case "I" are not included for the same reason. Such restrictions reduce the number of possible passwords. A script function that spells out the passwords phonetically allows us to include characters that would otherwise cause confusion.

The Spell-Phonetic script function accepts one or more strings, checks each string for complexity if requested, and outputs the strings followed by the phonetic spelling of each character. This output can be redirected to a text file for communication to others. If more than one string is processed by the function, the output for each string is separated by a form feed character. This character is recognized by applications like Microsoft Word, so that the printed output for each string is on a separate page.

The Spell-Phonetic function in this script uses the NATO spelling alphabet, also known as the ICAO phonetic alphabet. This alphabet includes the 26 letters of the English alphabet and the 10 numeric digits. But this function has been expanded to distinguish between upper and lower case letters and to include all of the symbols available on most computer keyboards. The function can be used with any script designed to generate passwords or security strings that must be communicated to others. For example, the function can be used with a script that generates product keys or pass codes. The Spell-Phonetic function as written handles 95 possible characters. Your script can use fewer characters. There are several examples of password generating scripts in the TechNet Gallery, but you might want to revise the one you use to include more characters if you also use this function.

If the Spell-Phonetic function encounters a nonstandard character (with ASCII code outside the range between 32 and 126), it simply uses the string "<unknown>" for the phonetic spelling. But the character is counted as a symbol when determining if the resulting string meets the complexity requirements.

The Spell-Phonetic.ps1 script can be dot sourced in a PowerShell session, making the Spell-Phonetic function available like any cmdlet. You can even pipe strings to the function. If the file Spell-Phonetic.ps1 is in the current directory you can dot source the function by entering the following at a PowerShell prompt.

PS> . .\Spell-Phonetic.ps1

That is a dot, followed by a space, followed by the path to the file, which in this case is .\Spell-Phonetic.ps1. Then some usage examples would be:

PS> Spell-Phonetic "xYz3#0l" -c -v

PS> "xYz3#0;" | Spell-Phonetic -l "Password" -c

Or the function will prompt for the strings, as in the below example:

PS> Spell-Phonetic

cmdlet Spell-Phonetic at command pipeline position 1
Supply values for the following parameters:
Strings[0]: x $`"34
Strings[1]
------------------
String: >>> x $`"34 <<<
Spelled out phonetically:
x (Lower case x as in xray)
  (Space)
$ (Dollar sign)
` (Backquote)
" (Quote)
3 (Number Three)
4 (Number Four)
------------------
PS>

Note that the strings ">>>" and "<<<" in the output are just to help indicate where the strings (passwords) begin and end. This helps if any strings begin or end with the space character. But the phonetic spelling removes any ambiguity.

You can also incorporate the function in a script that generates passwords, or other security strings. Just copy the function into your script.

Spell-Phonetic.txt <<-- Click here to view or download the program