$PSStyle

Format your PowerShell terminal using $PSStyle.

Download this Lecture

In this video, we look at how to use $PSStyle to format the output in your PowerShell terminal.

Code for this video can be found below.

"`e[44mTest"
$PSStyle
$PSStyle.Foreground
$PSStyle.Background
"$($PSStyle.Foreground.Magenta)Magenta"
"$($PSStyle.Foreground.Magenta)Magenta$($PSStyle.Reset)Not Magenta"
"$($PSStyle.Blink)Blink$($PSStyle.Reset) No Blink"

$PSStyle.Formatting.TableHeader = "`e[102m"
Get-Process | Select-Object -First 5

$PSStyle.Formatting.Warning = "`e[105m"
Write-Warning "Be careful!"

$psstyle.OutputRendering = "Plaintext"
Write-Warning "Be careful!"
Get-Process | Select-Object -First 5
$psstyle.OutputRendering = "ANSI"
Write-Warning "Be careful!"
Get-Process | Select-Object -First 5

$PSStyle.Progress.View = "Minimal"
$PSStyle.Progress.Style = "`e[102m"
1..100 | ForEach-Object { Start-Sleep -Milliseconds 100; Write-Progress -PercentComplete $_ -Activity "Progressing..." };

$PSStyle.Progress.View = "Classic"
1..100 | ForEach-Object { Start-Sleep -Milliseconds 100; Write-Progress -PercentComplete $_ -Activity "Progressing..." };

Enable-ExperimentalFeature PSANSIRenderingFileInfo

$psstyle.FileInfo
$PSStyle.FileInfo.Directory = "`e[33m"
$psstyle.FileInfo.Extension[".ps1"] = "`e[106m"
$PSStyle.FileInfo.Extension.add(".txt", "`e[102m")

Disable-ExperimentalFeature PSANSIRenderingFileInfo