How does one output bold text in powershell?

Just wording...
Seen from the 'ConvertFrom-MarkDown` cmdlet (included with PowerShell 6 and higher), bold text actually exists:
(Using the default PowerShell color scheme)

('This is **Bold** text' | ConvertFrom-MarkDown -AsVt100EncodedString).VT100EncodedString

enter image description here

But this is not completely fair, as behind the scenes, it is a matter of playing with colors. Knowing that the default foregroundcolor is Gray and White is just a little brigther and therefore looks Bold.
Meaning that the above statement is similar to:

Write-Host 'This is ' -NoNewline; Write-Host -ForegroundColor White 'Bold ' -NoNewline; Write-Host 'Text'

As far as I know it is not possible, but you can change the foregroundcolor and backgroundcolor of the text. This way you can output text in different colors, so you can highlight an error or a warning.


This displays a red text:

Write-Host "This text is red" -ForegroundColor red

This displays a blue text on a red background:

Write-Host "This text is blue" -ForegroundColor blue -BackgroundColor red

More here: https://evotec.xyz/powershell-how-to-format-powershell-write-host-with-multiple-colors/


See also:

Console Virtual Terminal Sequences

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

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

# Disable underline
$esc = [char]27
"$esc[0mReset"

Or as pointed out already, with Write-Host, just switch the text color inline for contrast...

Write-Host -ForegroundColor gray 'This is not bold ' -NoNewline
Write-Host -ForegroundColor White 'This is Bold ' -NoNewline
Write-Host -ForegroundColor gray 'This is not bold'

... that is if you did not download or can't download and use external stuff.