Using Symbols in Console Output

by | May 21,2015

Table of Contents

Did you know that console output can contain special icons like checkmarks? All you need to do is set the console to a TrueType font like “Consolas”.

To display special characters, use the decimal or hexadecimal character code, for example:

[Char]8730


[Char]0x25BA

Selecting an Alternative Iconic Character

Or launch the built-in application “CharacterMap” to pick another iconic character in the font you selected for the console.

Here is a sample that gets you a more sophisticated prompt in the PowerShell console:

function prompt
{

  $specialChar1 = [Char]0x25ba
  
  Write-Host 'PS ' -NoNewline
  Write-Host $specialChar1 -ForegroundColor Green -NoNewline
  ' '
  
  $host.UI.RawUI.WindowTitle = Get-Location
}

Understanding the Prompt Function Behavior

Note that a “prompt” function must return at least one character, or else PowerShell uses its default prompt. This is why the function returns a single space as return value, and uses Write-Host for color-coded output.

ReTweet this Tip!