Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Get-PhoneticString{
- param(
- [parameter(ValueFromPipeline=$true, Mandatory=$true)]
- [string]$StringToExplode,
- [string]$Delimiter = " - "
- )
- process{
- # Alphabetic conversions using military phonetics
- $phoneticAlphabet = @{
- "a" = "alfa"; "b" = "bravo"; "c" = "charlie"; "d" = "delta"; "e" = "echo";
- "f" = "foxtrot"; "g" = "golf"; "h" = "hotel"; "i" = "india"; "j" = "juliett";
- "k" = "kilo"; "l" = "lima"; "m" = "mike"; "n" = "november"; "o" = "oscar";
- "p" = "papa"; "q" = "quebec"; "r" = "romeo"; "s" = "sierra"; "t" = "tango";
- "u" = "uniform"; "v" = "victor"; "w" = "whiskey"; "x" = "x-ray"; "y" = "yankee";
- "z" = "zulu"
- }
- $numberAsString = @{
- "0"="zero"; "1"="one"; "2"="two"; "3"="three"; "4"="four"
- "5"="five"; "6"="six"; "7"="seven"; "8"="eight"; "9"="nine"
- }
- $symbolAsString = @{
- "!" = "Exclamation Mark"; '"' = "Double Quote"; "#" = "Number Sign"; "$" = "Dollar"; "%" = "Percent"; "&" = "Ampersand"
- "'" = "Single Quote"; "(" = "Left Parenthesis"; ")" = "Right Parenthesis"; "*" = "Asterisk"; "+" = "Plus"
- "," = "Comma"; "-" = "Minus"; "." = "Period"; "/" = "Slash"; ":" = "Colon"; ";" = "Semicolon"; "<" = "Less Than"
- "=" = "Equality Sign"; ">" = "Greater Than"; "?" = "Question Mark"; "@" = "At Sign"; "[" = "Left Square Bracket"
- "" = "Backslash"; "]" = "Right Square Bracket"; "^" = "Caret"; "_" = "Underscore"; '`' = "Grave / Accent"
- "{" = "Left Curly Bracket"; "|" = "Vertical Bar"; "}" = "Right Curly Bracket"
- }
- # Convert this string into a character array. For each character find its string equivilent in one of the defined hash tables
- ($StringToExplode.ToCharArray() | ForEach-Object{
- switch -Regex -CaseSensitive ($_){
- "[a-z]"{$phoneticAlphabet."$_"}
- "[A-Z]"{($phoneticAlphabet."$_").ToUpper()}
- "d"{$numberAsString."$_"}
- "s"{$_}# Return whitespace unaltered
- default{ $symbolAsString."$_"}
- }
- }) -join $Delimiter
- }
- }
- "K0D3R3v13w" | Get-PhoneticString
- KILO - zero - DELTA - three - ROMEO - three - victor - one - three - whiskey
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement