Changing color of error messages in PowerShell “Red is scary”

Hi Friends

This is going to be short blog about how we can change the color of error messages in PowerShell. By default its in “Red” and at least to me its scary. This is how it looks:

Untitled

Good news is that we can change this color and not only error but we can change warning color, background color and so on. These setting are in “private data” property of “$host”. Lets have a look.

Untitled1

So to change it use this cmdlet: $host.PrivateData.ErrorForegroundColor = ‘White’. I have changed color to white you can also use some other color. And here is the new look:

Untitled2

Isn’t it awesome.

Note: This change is only for the current session of shell. Once you close and reopen, changes are gone. To make it permanent you need to use “profile”. Have you said “Whats profile ?”. For those who questioned, here is the answer:

https://technet.microsoft.com/en-us/magazine/2008.10.windowspowershell.aspx

So, that’s all in this post or may be a diary note.

See you soon with some other technical stuff. Bye.

Advertisement

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