List of all colors available for PowerShell

PowerShell is a shell scripting language. At times we need to present different colors for different sections of the script output.

For PowerShell, console colors are in an enum called [System.ConsoleColor]. The list of colors can be obtained by calling the static method GetValues as below



Get-Module -ListAvailable | Where-Object {$_.Path -like "$PSHOME*"} | Import-Module


A graphical visualization of these colors with types of backgrounds can be visualized as below (code is written below to achieve the functionality):

colors = [enum]::GetValues([System.ConsoleColor])
Foreach ($bgcolor in $colors){
    Foreach ($fgcolor in $colors) { Write-Host "$fgcolor|"  -ForegroundColor $fgcolor -BackgroundColor $bgcolor -NoNewLine }
    Write-Host " on $bgcolor"