I got a Powershell script that do some automatic procedures, I use a "Write-Host" at the end of each one of them to tell the technical user that step is finished, but I realize is kind of hard to read and keep track so, ¿Is there a way to output a bold text?
Thank you in advance.
You can specify the color of text by using the ForegroundColor parameter, and you can specify the background color by using the BackgroundColor parameter. The Separator parameter lets you specify a string to use to separate displayed objects. The particular result depends on the program that is hosting PowerShell.
All you have to do is to go to Out-String and add the -Width parameter. Keep in mind that the -Width parameter of Out-File cmdlet specifies the number of characters in each line of output. Any other characters will simply be truncated, not wrapped.
The Format-Table cmdlet formats the output of a command as a table with the selected properties of the object in each column. The object type determines the default layout and properties that are displayed in each column. You can use the Property parameter to select the properties that you want to display.
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.
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
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'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With