Using Underlined Console Output

by Mar 26, 2018

Starting in PowerShell 5.1, the PowerShell console supports VT escape sequences that can be used to position and format console text. Note that this works in the console only, not the PowerShell ISE. Note also that you either need Windows 10 or an emulator like ConEmu.

To try this, run the code below in a PowerShell console:

$esc = [char]27
"$esc[4mOutput is now underlined!"

PowerShell now underlines all output. Input text is not underlined (as PSReadLine takes care of text formatting for all input text).

To turn formatting off, run this:

$esc = [char]27

We’ll look into console text formatting in more detail in tips to come. Here is further reading for VT escape sequences:

Twitter This Tip! ReTweet this Tip!