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

[Enum]::GetValues([System.ConsoleColor])

or

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

[Enum]::GetValues([ConsoleColor])

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"
}
Ref: https://gist.github.com/timabell/cc9ca76964b59b2a54e91bda3665499e