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.