A lot of my PowerShell work lately has involved color. I find myself using ANSI escape sequences quite often. I'm also playing with different color schemes in Windows Terminal. And I still on occasion find myself using Write-Host to display colorized messages. What has gotten trickier is that Windows Terminal schemes can redefine colors. What I am used to as Green may not actually be Green. I polished up a simple script, to display all possible combinations for the console colors.
ManageEngine ADManager Plus - Download Free Trial
Exclusive offer on ADManager Plus for US and UK regions. Claim now!
#requires -version 5.1
#Display a combination of foreground and background console colors
#create an array of system console colors
$colors = [enum]::GetNames([consolecolor])
<#
combine the color as foreground in combination with every color
as a background
#>
foreach ($bg in $colors) {
Clear-Host
foreach ($fg in $colors) {
$msg = "This is a $fg foreground on a $bg background"
Write-Host $msg.PadRight(75, ' ') -ForegroundColor $fg -BackgroundColor $bg
} #foreach $bg
#pause for each background
Write-Host " "
Pause
} #foreach $fg
The script will cycle through all of the console colors, pausing after each. Here's what this looks like in a traditional Windows PowerShell session.
This makes it easy to identify a good color combination. But notice what happens in Windows Terminal.
You can see that DarkGreen isn't really what it says it is. But, this helps me select an appropriate console color.
Not all my Windows Terminal color schemes are as quite dramatic as this one, but regardless, I now have a quick script I can run to get a preview of what I can expect. Hope you find this handy.