Quick tip: Easy access to special symbols

In this quick tip, I’m going to show you a way to organize and quickly access special symbols in PowerShell.
You might know that you can access a characters ASCII value by the following command

[int][char]'%'

By using this command we are getting the ASCII value of the ‘%’ character. But there are more ASCII characters, or symbols, than we have easy access to through the keyboard. The way to access these symbols are like this

[char]9834

This command will display a note symbol.

If you have a small collection of these symbols you would like to have within easy reach, just collect them all in an object, and add it to your PowerShell profile for ease of access. I have created a starter object for you that you can start with if you want.


$symbols = [PSCustomObject] @{
SMILEY_WHITE = ([char]9786)
SMILEY_BLACK = ([char]9787)
GEAR = ([char]9788)
HEART = ([char]9829)
DIAMOND = ([char]9830)
CLUB = ([char]9827)
SPADE = ([char]9824)
CIRCLE = ([char]8226)
NOTE1 = ([char]9834)
NOTE2 = ([char]9835)
MALE = ([char]9794)
FEMALE = ([char]9792)
YEN = ([char]165)
COPYRIGHT = ([char]169)
PI = ([char]960)
TRADEMARK = ([char]8482)
CHECKMARK = ([char]8730)
}

view raw

symbols.ps1

hosted with ❤ by GitHub

Using this object, you can try out the following commands to see how it works

Write-Host "Done with task #1 $($symbols.CHECKMARK)"
Write-Host "CompanyName$($symbols.TRADEMARK) $($symbols.COPYRIGHT) 2015"

Please note though, that the available ASCII symbols varies between character sets (fonts). So if you use a specific font, and use characters that are unique to that font, your colleague will probably not see that symbol unless he/she is using the same font as you.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s