Altering the background color of a PowerShell session

By | November 24, 2010

I was fiddling about with PowerShell the other day after being quite upset that the default SharePoint Admin Shell comes with a black background and not the nifty dark blue that we have all come to love about PowerShell.

In my stumbling around in various books I have collected on PowerShell, I came across a handy little line of goodness:

$host.UI.RawUI.BackgroundColor = “Darkblue”; cls

Nothing too fancy, but it will let you change the background to any one of the following:

  • Black
  • DarkBlue
  • DarkGreen
  • DarkCyan
  • DarkRed
  • DarkMagenta
  • DarkYellow
  • Gray
  • DarkGray
  • Blue
  • Green
  • Cyan
  • Red
  • Magenta
  • Yellow
  • White

None of these actually match the default blue background, but hey-ho; nothing is ever perfect.

Handy for me was the ability to switch the background color (minus the cls) to highlight different areas of a script to the user.

Nice in combination with a “Write-Host -ForegroundColor” to really bring home a point in a script.

You can, of course, pass a color to PowerShell as part of its start-up, but the approach outlined here lets you switch the color on the fly which may just come in handy.

2 thoughts on “Altering the background color of a PowerShell session

  1. advanced vision care

    Hey! I know this is somewhat off topic but I was wondering
    if you knew where I could locate a captcha plugin for my
    comment form? I’m using the same blog platform as yours and I’m having problems finding one?
    Thanks a lot!

    1. sebmatthews Post author

      I use Akismet and JetPack you can find them both on the WordPress Plugins site
      Good luck!


Leave a Reply

Your email address will not be published. Required fields are marked *