Gary's $this and that about PowerShell

I am a Microsoft Senior Premier Field Engineer based out of Atlanta, GA. My focus is Powershell. This blog is mainly to share interesting Powershell script samples.

Sample all PowerShell Console Colors

Sample all PowerShell Console Colors

  • Comments 2
  • Likes

I often need to pick console colors to use making host text a little easier to look at (coupled with smart indentation).  The –Foregroundcolor parameter of the Write-Host cmdlet is what I commonly use to set text colors.  I like to use lots of colors, but sometimes I forget what all the colors are and what they look like (the look is more important).  The Intellisense in the v3+ ISE is great that it suggests the color names (tab completion will as well), but sometimes I need to be reminded of what each looks like.  Here is a simple little one-liner that will show the color names in their appropriate color.  I use this line every so often to remind me.

PS > [enum]::GetValues([System.ConsoleColor]) | Foreach-Object {Write-Host $_ -ForegroundColor $_}      

Black        

DarkBlue      

DarkGreen      

DarkCyan      

DarkRed      

DarkMagenta      

DarkYellow      

Gray      

DarkGray      

Blue      

Green      

Cyan    

Red      

Magenta      

Yellow

White <-- White is here, but you can’t see it)

Hopefully this trick helps someone out.

-Gary Siepser

Comments
  • Thanks for this

  • SCCM

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment