Prof. Powershell

Cool ISE

At the heart of this awesome no-frills editor is the $psise object, handy for configuring the ISE how you want it.

The Windows PowerShell Integrated Script Editor, also known as the ISE, is a terrific no-frills script editor at a great price ... free! It is installed by default on Windows 7 and can be set up as an optional component on other operating systems. What I especially enjoy about the ISE is that it has its own object model, which means you can automate its configuration.

At the heart is the intrinsic $psise object which you can see in the ISE.

PS C:\> $psise | format-list

CurrentPowerShellTab : Microsoft.PowerShell.Host.ISE.PowerShellTab
CurrentFile          : Microsoft.PowerShell.Host.ISE.ISEFile
Options              : Microsoft.PowerShell.Host.ISE.ISEOptions
PowerShellTabs       : {PowerShell 1}

What I want to talk about in today's lesson is the Options property, which is a nested object with its own set of properties. Let's take a look at the default.

PS C:\> $psise.options

SelectedScriptPaneState       : Top
ShowToolBar                   : True
TokenColors                   : {[Attribute, #FFADD8E6],
                                [Command, #FF0000FF],
                                [CommandArgument, #FF8A2BE2],
                                [CommandParameter, #FF000080]...}
DefaultOptions                : Microsoft.PowerShell.Host.ISE.ISEOptions
FontSize                      : 16
FontName                      : Lucida Console
ErrorForegroundColor          : #FFFF0000
ErrorBackgroundColor          : #00FFFFFF
WarningForegroundColor        : #FFFF8C00
WarningBackgroundColor        : #00FFFFFF
VerboseForegroundColor        : #FF0000FF
VerboseBackgroundColor        : #00FFFFFF
DebugForegroundColor          : #FF0000FF
DebugBackgroundColor          : #00FFFFFF
OutputPaneBackgroundColor     : #FFF0F8FF
OutputPaneTextBackgroundColor : #FFF0F8FF
OutputPaneForegroundColor     : #FF000000
CommandPaneBackgroundColor    : #FFFFFFFF
ScriptPaneBackgroundColor     : #FFFFFFFF
ScriptPaneForegroundColor     : #FF000000
ShowWarningForDuplicateFiles  : True
ShowWarningBeforeSavingOnRun  : True
UseLocalHelp                  : True
CommandPaneUp                 : False

What can we do with this? Well, perhaps you prefer a different color background for the output pane.

$psise.Options.OutputPaneBackgroundColor="Cyan"

The middle output panel now has a new color. If you run a command like Get-Service you'll notice the command output background is still white. To complete the transformation try this:

$psise.Options.OutputPaneTextBackgroundColor="Cyan"

That should do the trick, although you might still need a Clear-Screen command to force the change. You can change the color of a number of features.

I also like being able to change the font.

$psise.Options.FontName="Courier New"
$psise.Options.FontSize=20

You'll get best results sticking with a fixed width font. If you don't like the changes you made, exit and restart the ISE and you'll be back to normal. Of course, if you always want a specific configuration then add the necessary lines into your ISE profile script:

C:\Users\USERNAME\Documents\WindowsPowerShell\Microsoft.PowerShellISE_profile.ps1

Another possibility is to use a theme script. MVP Thomas Lee has posted a few scripts that extensively configure the ISE. One "theme" script will configure the ISE fonts and colors to that it looks like the venerable VIM editor. You might also want to grab his "reset" script from here.

I think these scripts open up all sorts of possibilities. If you come up with a theme script for the ISE, I hope you'll share it.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular