One of the topics I inject into every one of my classes (and frankly, most of my customer conversations) is how to do whatever we are doing in PowerShell. Scripting is one of the ways I make my life easier, and I recommend my students and customers use the knowledge I share to make their lives easier.
One of the differences between a Command Shell window and a PowerShell window is the colours. Command Shell is white type on a black background. PowerShell is a blue background, with the type colours varying depending on the context… Yellow for cmdlets, red for errors, and so on.
One of my students recently told me that because of the issues he has with his eyes, he has trouble reading the red writing on the blue background, and asked if there was a way to change it. I honestly had never thought of it… so I decided to do some research.
It turns out, according to what I discovered, it is possible to change a lot of the colours in PowerShell. Let’s start by changing the colour of the error messages:
$host.PrivateData.ErrorForegroundColor = “Green”
So let’s see what that does:
Okay, that is much better. We can also change the background colour of the error text (black by default), by using this:
$host.PrivateData.ErrorBackgroundColor = “DarkCyan”
Granted, I hate the colour, but once you know the command, you can play with the colours that you want.
As well, if you want to change the colour scheme of the entire console, you can use the following:
[console]::ForegroundColor = “Yellow”
[console]::BackgroundColor = “black”
Now we have the entire console in black, and the default text in yellow.
If you want to use these colours persistently, you can insert them into your profile… or just create a .ps1 file that you run every time you open PowerShell.
Jeff Hicks wrote a number of great scripts a few years ago that will let you manage your colour schemes, and they can be found here. Unfortunately it is an older article and the images are gone, but the scripts are intact, and that is the important part.
Leave a Reply