Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

PowerShell Color Combos

Posted on October 1, 2020October 1, 2020

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.

Manage and Report Active Directory, Exchange and Microsoft 365 with
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.


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

reports

Powered by Buttondown.

Join me on Mastodon

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2025 The Lonely Administrator | Powered by SuperbThemes!
%d