Ok, so errors are never actually pleasing regardless of what color they are. But maybe you’ve been working with PowerShell for a while and or are just dipping your toes in the water and for one reason or another, you are seeing more red than anything else on your screen.
Wouldn’t it be great to have a slightly less intimidating color to display an error message to you? If your answer is yes, then continue reading. If no, well… move along, nothing to see here.
The answer to how to change the color of the error message lies in PrivateData property of $host (which is an automatic variable which represents the current host application for PowerShell). Let’s take a look at what is currently set in this object.
As you can see, each type of stream; Error, Warning,Debug,Verbose and Progress has both a Background and Foreground color assigned to it by default. Luckily for us, these can be changed rather easily. But what colors can we choose from? Let’s find out.
Changing the error foreground color is as easy as
$host.PrivateData.ErrorForegroundColor = 'White'
There we go, now those error messages are not so intimidating to us. Pretty simple, isn’t it? Now you have a way to make not only the errors displayed in a different color, but even verbose, warning, etc… Just add some lines to your PowerShell profile and you are on your way!