Resetting Console Colors

by Oct 20, 2010

While there are two paths for changing the console color, will you be able to revert back to the original settings once you set colors via [System.Console]. Have a look:

[System.Console]::BackgroundColor = 'Blue'
[System.Console]::ForegroundColor = 'Yellow'
Clear-Host

This creates a blue console with yellow text. If you want to get back to the original color settings, you can simply call:

[System.Console]::ResetColor()
Clear-Host

If you had changed colors using the PS object model through $host.UI.RawUI.BackgroundColor = 'Blue', ResetColor() would not return to the original color.

Twitter This Tip!
ReTweet this Tip!