I want to make the font as bold for the path that I'm printing using Write-Host. I'm flexible to using other methods like echo or something else.
I've tried other methods like Write-Debug, etc, also checked the module WindowsConsoleFonts.
But none of them supports font properties like making them bold or italic while printing them.
$pathString = "[" + (Get-Location) + "]"
Write-Host $pathString -ForegroundColor Cyan
I'm using PowerShell 5.1 which doesn't support MarkDown rendering, else I would have done it using Markdown.
Some built-in ANSI text formatting sequences were added in PowerShell 7.2 (PSCore). They are accessible via the $PSStyle variable/object. More documentation can be found at about_ANSI_Terminals (Microsoft link).
Try entering $PSStyle.Formatting, $PSStyle.Foreground, $PSStyle.Background (or simply $PSStyle) at a PowerShell prompt for a list of some supported styles and formatters.
Write-Host "hello $($PSStyle.bold)bold$($PSStyle.BoldOff) world"
$PSStyle.Foreground
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