Color Week: Using Transparency in the PowerShell ISE Console

by Sep 15, 2016

This week we are looking at how you can change coloring both in the PowerShell console and PowerShell ISE so you can fine tune your PowerShell environment.

In the previous tips you learned that three settings govern the colors in the PowerShell ISE Console Pane. If you want, you can set a different background color for input and output:

 
$psise.Options.ConsolePaneForegroundColor=[System.Windows.Media.Colors]::LightSkyBlue
$psise.Options.ConsolePaneBackgroundColor=[System.Windows.Media.Colors]::DarkGreen
$psise.Options.ConsolePaneTextBackgroundColor=[System.Windows.Media.Colors]::Yellow

The result would look similar to this:

PS C:\>"Hello"
Hello
 
PS C:\>$Host
 
 
Name            : Windows PowerShell ISE Host
Version         : 4.0
InstanceId      : 840b9f0e-0c05-4b6d-84fc-c104971ac647
UI              : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture  : de-DE
CurrentUICulture: de-DE
PrivateData     : Microsoft.PowerShell.Host.ISE.ISEOptions
IsRunspacePushed: False
Runspace        : System.Management.Automation.Runspaces.LocalRunspace

If you just planned to highlight the output a little bit, you might want to use transparent colors. The background color for text can be made transparent when you first determine the color code for the color you want to use, and then create a self-defined color with alpha channel. It’s much easier than it seems.

In the previous example, the text background color was “Yellow”. Here is how you find out the actual color value for “Yellow”:

 
PS C:\> [System.Windows.Media.Colors]::Yellow.ToString()
#FFFFFF00

The first hexadecimal represents the alpha channel (opacity). To get a yellow color with more transparency, just lower that value:

 
PS>$psise.Options.ConsolePaneTextBackgroundColor="#33FFFF00"

Twitter This Tip! ReTweet this Tip!