I posted a new wiki doc that explains how you can change the syntax highlighting colors of the PSReadLine module that comes with PowerShell. The doc also describes how you change the general console colors with PowerShell. However, I  ran into some trouble with the Set-PSReadlineOption cmdlet. Maybe you can help?
Latest posts by Michael Pietroforte (see all)

Colors are a matter of taste. Many of the older geeks prefer a console with a black background and a green foreground color. I suppose it reminds them of the good old days when we only had monochrome computer screens (so-called green screens) and Paul Allen and Steve Wozniak had not yet stolen the GUI technology from Xerox PARC.

Computer screens in the good old days

Computer screens in the good old days

Thus, I guess many hardcore console enthusiasts didn't really like it when Microsoft included PSReadLine in PowerShell 5. I already liked the module before that. I like colors. I find syntax highlighting quite helpful for avoiding typos and, in my view, it not only makes sense for scripting but also on a console.

The problem is that when you change the background color of your console (through the console properties), the default PSReadLine colors often don't fit anymore. The good thing is that you can change the default PSReadLine colors, although it is not as straightforward as in modern terminal applications where you can often choose from a wide range of colors in a GUI. The PowerShell console offers only a very limited number of colors. I explained everything in detail in the wiki. Please help improve the document by editing it.

In theory, the Set-PSReadlineOption cmdlet allows you to do more than set the colors of tokens. According to Microsoft's documentation, the cmdlet also supports parameters such as -ContinuationPromptForegroundColor, -ContinuationPromptBackgroundColor, -EmphasisForegroundColor, -EmphasisBackgroundColor, -ErrorForegroundColor, and -ErrorBackgroundColor.

For instance, to set the background color for errors to blue, this command is supposed to make the change:

Changing the background color for error messages is not working

Changing the background color for error messages is not working

Subscribe to 4sysops newsletter!

In practice, this command didn't work for me. It didn't throw an error message in my test, but it didn't change the colors, either. Maybe I misunderstood something here? Enlighten me please!

  1. Hi Michael,

    you can refer to this post to get the answer.

    Its because the functionality you are looking for is not provided by PSreadline, but its console settings (get-host).

    Hope it helps



  2. Author

    Leos, thanks. I explained all the possible ways of how to change the PowerShell console colors in the wiki. Actually, more options exist than mentioned in the Technet article.

    However, I wonder what PSReadline parameters like -ErrorBackgroundColor are for? They seem to have no effect. A bug?


  3. I dont have answer for that. But its not what you asked in your original post showing error message with unknown command. Thats not controlled by PSreadline but by the settings of console 🙂

    I wish you Happy New Year and a lot of motivation to continue the good work with this site 🙂

    Ill deliver my article during January 🙂



Leave a reply

Please enclose code in pre tags

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


© 4sysops 2006 - 2021


Please ask IT administration questions in the forums. Any other messages are welcome.


Log in with your credentials


Forgot your details?

Create Account