PowerShell’s Docs General PowerShell Docs Change PowerShell console syntax highlighting colors of PSReadLine

You can change the PowerShell console colors of the PSReadLine module that Microsoft delivers with PowerShell since version 5. We have to distinguish between colors for tokens of a certain type (for examples cmdlets or strings) and the colors of console itself.

Latest posts by Michael Pietroforte (see all)

Token colors

To get an overview of your current color settings, you can use this command:

Get-PSReadlineOption | Select *color
Displaying the PowerShell console color settings

Displaying the PowerShell console color settings

To change the colors, you can use the Set-PSReadlineOption cmdlet. However, you can't just use the parameters you see in the above screenshot. This is the syntax of the cmdlet:


[-TokenKind] <TokenClassification>

[[-ForegroundColor] <ConsoleColor>]

[[-BackgroundColor] <ConsoleColor>]

The TokenKind parameter specifies the type of item for which you can change the color. Say you want to change the color of the variables; then TokenKind Variable. Or if you want to change color of the cmdlets, the TokenKind is Command. The latter corresponds to CommandForegroundColor in the screenshot above. These are the supported TokenKind parameters: None, Comment, Keyword, String, Operator, Variable, Command, Parameter, Type, Number, and Member.

For instance, if you want to change the CommandForegroundColor to white, you need this command:

Set-PSReadlineOption -TokenKind Command -ForegroundColor White
Changing the command foreground color

Changing the command foreground color

If you want to reset all token colors to the default configuration, then this command helps:

Set-PSReadlineOption -ResetTokenColors

Console colors

You can change the general background colors through the $host.ui.rawui object and the colors for errors and warnings through the $Host.PrivateData object.

For instance, to change the general background color of the console to black, you can use this command:

$host.ui.rawui.BackgroundColor = "Black"

And if you want to replace the red PowerShell error messages, these commands do the trick:

$Host.PrivateData.ErrorBackgroundColor = "Blue"
$Host.PrivateData.ErrorForegroundColor = "White"
Changing the colors of error messages

Changing the colors of error messages

Here is the complete list:

$host.ui.rawui.ForegroundColor = <ConsoleColor>
$host.ui.rawui.BackgroundColor = <ConsoleColor>
$Host.PrivateData.ErrorForegroundColor = <ConsoleColor>
$Host.PrivateData.ErrorBackgroundColor = <ConsoleColor>
$Host.PrivateData.WarningForegroundColor = <ConsoleColor>
$Host.PrivateData.WarningBackgroundColor = <ConsoleColor>
$Host.PrivateData.DebugForegroundColor = <ConsoleColor>
$Host.PrivateData.DebugBackgroundColor = <ConsoleColor>
$Host.PrivateData.VerboseForegroundColor = <ConsoleColor>
$Host.PrivateData.VerboseBackgroundColor = <ConsoleColor>
$Host.PrivateData.ProgressForegroundColor = <ConsoleColor>
$Host.PrivateData.ProgressBackgroundColor = <ConsoleColor>

Available colors

As mentioned above, the number of colors you can choose from is somewhat limited: Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, and White.

To see how the colors look you can install the TMOutput module:

Install-Module -Name TMOutput

You can the display the colors with the Show-TMOutputColor cmdlet:

Subscribe to 4sysops newsletter!

Displaying available PSReadLine colors

Displaying available PSReadLine colors

To make your color changes permanent, you have to add the commands to one of your PowerShell profiles.

Discussion (14)

  1. I tried with the the current version installed with Windows 1903 and the help file mentions TokenKind but it doesn't recognize the paramater.  I had to do Set-PSReadlineOption -Colors @{Command = "Blue"} as an example.

  2. Moving forward, the -TOKENKIND parameter is gone. The advice in this article no longer applies to the latest versions of PowerShell 7. 

  3. There are no words to describe how much I hate what Microsoft did here.  I am working on a VM, it is past midnight and the standard color scheme is very difficult to read.  For some ridiculous trendy reason, the background on PowerShell is black.  I went in and changed the text to black and the background to white.  i did this in Default and Properties.  Well, because of the syntax highlighting, my color changes did not do what I think any reasonable person would expect.  The background did become white, but the text was yellow and it was even harder to read. 

    I found you very informative article and surprise, surprise, Microsoft provides a great deal of customizability, but not through their GUI.  It is very hard to type the commands when I can't read what I am typing.  There should be a light mode and a dark mode and then if someone wants to go to the trouble to change specific aspects of the syntax to their favorite color, then they can type in all the commands.  

    So, thank you for helping me find out what Microsoft couldn't bother to tell me.  Microsoft, if you are listening, it is stupid things like this that make people hate your environment.  

    • In the upcoming new world, it will be less relevant whether people hate a vendor for such things, because they typically don't care — instead, they will be financially liable for the wasted time users encounter when standard instructions no longer work.

  4. In the upcoming world of 2022, I had to do this nonsense to set colors that work with a black Fluent Terminal background:

    Get-PSReadlineOption  # list all.  (alias: just 'psreadlineoption')
    Set-PSReadLineOption -Colors @{ "Command"="White" }
    Set-PSReadLineOption -Colors @{ "Operator"="DarkBlue" }
    Set-PSReadLineOption -Colors @{ "String"="Yellow" }
    Set-PSReadLineOption -Colors @{ "Parameter"="Blue" }
    Set-PSReadLineOption -Colors @{ "Comment"="Gray" }
    # which syntax I found here:
    get-help Set-PSReadLineOption -examples

  5. I have used all these, many are most likely duplicate colors, but they all work

    $Colors = @()

    $Colors += “AliceBlue”
    $Colors += “AntiqueWhite”
    $Colors += “Aqua”
    $Colors += “Aquamarine”
    $Colors += “Azure”
    $Colors += “Beige”
    $Colors += “Bisque”
    $Colors += “Black”
    $Colors += “BlanchedAlmond”
    $Colors += “Blue”
    $Colors += “BlueViolet”
    $Colors += “Brown”
    $Colors += “BurlyWood”
    $Colors += “CadetBlue”
    $Colors += “Chartreuse”
    $Colors += “Chocolate”
    $Colors += “Coral”
    $Colors += “CornflowerBlue”
    $Colors += “Cornsilk”
    $Colors += “Crimson”
    $Colors += “Cyan”
    $Colors += “DarkBlue”
    $Colors += “DarkCyan”
    $Colors += “DarkGoldenrod”
    $Colors += “DarkGray”
    $Colors += “DarkGreen”
    $Colors += “DarkKhaki”
    $Colors += “DarkMagenta”
    $Colors += “DarkOliveGreen”
    $Colors += “DarkOrange”
    $Colors += “DarkOrchid”
    $Colors += “DarkRed”
    $Colors += “DarkSalmon”
    $Colors += “DarkSeaGreen”
    $Colors += “DarkSlateBlue”
    $Colors += “DarkSlateGray”
    $Colors += “DarkTurquoise”
    $Colors += “DarkViolet”
    $Colors += “DeepPink”
    $Colors += “DeepSkyBlue”
    $Colors += “DimGray”
    $Colors += “DodgerBlue”
    $Colors += “Firebrick”
    $Colors += “FloralWhite”
    $Colors += “ForestGreen”
    $Colors += “Fuchsia”
    $Colors += “Gainsboro”
    $Colors += “GhostWhite”
    $Colors += “Gold”
    $Colors += “Goldenrod”
    $Colors += “Gray”
    $Colors += “Green”
    $Colors += “GreenYellow”
    $Colors += “Honeydew”
    $Colors += “HotPink”
    $Colors += “IndianRed”
    $Colors += “Indigo”
    $Colors += “Ivory”
    $Colors += “Khaki”
    $Colors += “Lavender”
    $Colors += “LavenderBlush”
    $Colors += “LawnGreen”
    $Colors += “LemonChiffon”
    $Colors += “LightBlue”
    $Colors += “LightCoral”
    $Colors += “LightCyan”
    $Colors += “LightGoldenrodYellow”
    $Colors += “LightGray”
    $Colors += “LightGreen”
    $Colors += “LightPink”
    $Colors += “LightSalmon”
    $Colors += “LightSeaGreen”
    $Colors += “LightSkyBlue”
    $Colors += “LightSlateGray”
    $Colors += “LightSteelBlue”
    $Colors += “LightYellow”
    $Colors += “Lime”
    $Colors += “LimeGreen”
    $Colors += “Linen”
    $Colors += “Magenta”
    $Colors += “Maroon”
    $Colors += “MediumAquamarine”
    $Colors += “MediumBlue”
    $Colors += “MediumOrchid”
    $Colors += “MediumPurple”
    $Colors += “MediumSeaGreen”
    $Colors += “MediumSlateBlue”
    $Colors += “MediumSpringGreen”
    $Colors += “MediumTurquoise”
    $Colors += “MediumVioletRed”
    $Colors += “MidnightBlue”
    $Colors += “MintCream”
    $Colors += “MistyRose”
    $Colors += “Moccasin”
    $Colors += “NavajoWhite”
    $Colors += “Navy”
    $Colors += “OldLace”
    $Colors += “Olive”
    $Colors += “OliveDrab”
    $Colors += “Orange”
    $Colors += “OrangeRed”
    $Colors += “Orchid”
    $Colors += “PaleGoldenrod”
    $Colors += “PaleGreen”
    $Colors += “PaleTurquoise”
    $Colors += “PaleVioletRed”
    $Colors += “PapayaWhip”
    $Colors += “PeachPuff”
    $Colors += “Peru”
    $Colors += “Pink”
    $Colors += “Plum”
    $Colors += “PowderBlue”
    $Colors += “Purple”
    $Colors += “Red”
    $Colors += “RosyBrown”
    $Colors += “RoyalBlue”
    $Colors += “SaddleBrown”
    $Colors += “Salmon”
    $Colors += “SandyBrown”
    $Colors += “SeaGreen”
    $Colors += “SeaShell”
    $Colors += “Sienna”
    $Colors += “Silver”
    $Colors += “SkyBlue”
    $Colors += “SlateBlue”
    $Colors += “SlateGray”
    $Colors += “Snow”
    $Colors += “SpringGreen”
    $Colors += “SteelBlue”
    $Colors += “Tan”
    $Colors += “Teal”
    $Colors += “Thistle”
    $Colors += “Tomato”
    $Colors += “Turquoise”
    $Colors += “Violet”
    $Colors += “Wheat”
    $Colors += “White”
    $Colors += “WhiteSmoke”
    $Colors += “Yellow”
    $Colors += “YellowGreen”

    I have them in an array so I can add them to a dropdown box and change colors on the fly in some applications

Leave a Reply to flaxe Cancel reply

Please enclose code in pre tags: <pre></pre>

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

© 4sysops 2006 - 2023


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


Log in with your credentials


Forgot your details?

Create Account