Sunday, December 31, 2006

PowerShell Colours

The default colour scheme for PowerShell RTM relies on the defaults for cmd.exe, namely white text on background, and a relatively small window. I prefer to change the defaults in my profile.ps1 file as follows:

# set standard colours etc
$host.ui.rawui.WindowTitle = "PowerShell Rocks!!!"
$host.ui.rawui.backgroundcolor="white"
$host.ui.rawui.foregroundcolor="darkblue"
$host.ui.rawui.buffersize.width=120
$host.ui.rawui.buffersize.height=9999
$host.ui.rawui.windowsize.width=120
$host.ui.rawui.windowsize.height=42
# error and warning colours
$host.privatedata.errorbackgroundcolor="darkblue"
$host.privatedata.errorforegroundcolor="white" $host.privatedata.warningbackgroundcolor="white"
$host.privatedata.warningforegroundcolor="red"

As you can see, you set the basic colours with $host.ui.rawui properties, but set the error/warning colours using $host.privatedata properties. If you want to see what the colours look like for errors or warnings, you can use write-warning and write-error cmdlets as shown in this screenshot:

 

1 comment:

PReetamZ said...

Thank you for helping in getting rid of Red color, Everytime I try something, red color keeps bugging me and then without reason I keep using cls, every 1 min...hahaha..