PowerShell – Hate The Error Text And Warning Text Colors? Change It!

How could such a nice tool have such a terrible choice of colors for errors and warnings? I am talking about the ISE and the unreadable contrast of colors.

You can fix it. Open and update your profile by running this from your ISE (which opens your profile in NotePad)
notepad $profile

# Change the color of error and warning text
$opt = (Get-Host).PrivateData
$opt.WarningBackgroundColor = "Orange"
$opt.WarningForegroundColor = "white"
$opt.ErrorBackgroundColor = "red"
$opt.ErrorForegroundColor = "white"

Add the above to your profile. Save. Your ISE will have better colors for errors and warnings going forward (after a restart). For it to take effect immediately, just run it.

As a matter of fact, this is the color combination I have been using for a while and I cringe every time I see the default error/warning colors.

These colors are much better for Error and Warning – IMHO

PS C:\Windows\system32> Write-Error “This is a test error to show the error colors!”

[0,0: Write-Error] This is a test error to show the error colors!

PS C:\Windows\system32> Write-Warning “This is a test warning to show the warning colors!”

WARNING: This is a test warning to show the warning colors!

PS C:\Windows\system32>                


6 thoughts on “PowerShell – Hate The Error Text And Warning Text Colors? Change It!

  1. The property ‘ErrorForegroundColor’ cannot be found on this object. Verify that the property exists and can be set.
    At C:\Users\snyde\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1:4 char:1
    + $opt.ErrorForegroundColor = “white”
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

    1. I got Paul’s error message when I forgot to initialise the variable $opt using
      $opt = (Get-Host).PrivateData

  2. Property “Orange” not recognised. I get the following error message:

    Exception setting “WarningBackgroundColor”: “Cannot convert value “Orange” to type “System.ConsoleColor”. Error: “Unable to match the identifier name Orange to a valid enumerator
    name. Specify one of the following enumerator names and try again:
    Black, DarkBlue, DarkGreen, DarkCyan, DarkRed, DarkMagenta, DarkYellow, Gray, DarkGray, Blue, Green, Cyan, Red, Magenta, Yellow, White””
    At D:\Users\bodragon\Documents\WindowsPowerShell\profile.ps1:19 char:1
    + $opt.WarningBackgroundColor = “Orange”
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [], SetValueInvocationException
    + FullyQualifiedErrorId : ExceptionWhenSetting

    Please, why does this happen with me ?

    Windows 10 Enterprise
    Build 18362.19h1_release.190318-1202

    1. This post has become stale. It looks like Orange is no longer a valid color in the new version. Why don’t you try replacing “Orange” with one of the suggested colors. I would pick DarkYellow or Red.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s