The Options object represents various settings for the Windows PowerShell ISE. It is an instance of the Microsoft.PowerShell.Host.ISE.ISEOptions class.

Methods

RestoreDefaultTokenColors()

Restores the default values of the token colors.

# Changes the color of the comments in the script to red and then restores it to its default value.
$psISE.Options.TokenColors["Comment"]="red"
$psISE.Options.RestoreDefaultTokenColors()

RestoreDefaults()

Restores the default values of all options settings. It also resets the behavior of various warning messages that provide the standard check box for "Don't show me this message again."

# Changes the background color in the Command Pane and then restores it to its default value.
$psISE.Options.CommandPaneBackground = "orange"
$psISE.Options.RestoreDefaults()

Properties

CommandPaneBackgroundColor

Read/write property that gets or sets the background color for the Command Pane editor. It is an instance of the System.Windows.Media.Color class.

# Changes the background color of the Command Pane to orange. 
$psISE.Options.CommandPaneBackground = "orange"

CommandPaneUp

Read/write property that gets or sets a Boolean value that indicates whether the Command Pane is located above the Output Pane.

# Moves the Command Pane to the top of the screen.
$psISE.Options.CommandPaneUp  = $true

DebugBackgroundColor

Read/write property that gets or sets the background color for the debug text that appears in the Output Pane. It is an instance of the System.Windows.Media.Color class.

# Changes the background color for the debug text that appears in the Output Pane to blue. 
$psISE.Options.DebugBackgroundColor ='#0000FF'

DebugForegroundColor

Read/write property that gets or sets the foreground color for the debug text that appears in the Output Pane. It is an instance of the System.Windows.Media.Color class.

# Changes the foreground color for the debug text that appears in the Output Pane to yellow. 
$psISE.Options.DebugForegroundColor =”yellow”

DefaultOptions

Read-only property that gets the default values of the option settings.

# Displays the name of the default options. 
$psISE.Options.DefaultOptions
# Here is a typical listing of the default options:
SelectedScriptPaneState       : Right
ShowToolBar                   : True
TokenColors                   : {[Attribute, #FFADD8E6], [Command, #FF0000FF], [Com
                                mandArgument, #FF8A2BE2], [CommandParameter, #FF000
                                080]...}
DefaultOptions                : Microsoft.PowerShell.Host.ISE.ISEOptions
FontSize                      : 12
FontName                      : Lucida Console
ErrorForegroundColor          : #FF0000FF
ErrorBackgroundColor          : #00FFFFFF
WarningForegroundColor        : #FFFF8C00
WarningBackgroundColor        : #00FFFFFF
VerboseForegroundColor        : #FF0000FF
VerboseBackgroundColor        : #00FFFFFF
DebugForegroundColor          : #FF0000FF
DebugBackgroundColor          : #00FFFFFF
OutputPaneBackgroundColor     : #FFF0F8FF
OutputPaneTextBackgroundColor : #FFF0F8FF
OutputPaneForegroundColor     : #FF000000
CommandPaneBackgroundColor    : #FFFFFFFF
ScriptPaneBackgroundColor     : #FFFFFFFF
ShowWarningForDuplicateFiles  : True
ShowWarningBeforeSavingOnRun  : True
UseLocalHelp                  : True
CommandPaneUp                 : False

ErrorBackgroundColor

Read/write property that gets or sets the background color for the error text that appears in the Output Pane. It is an instance of the System.Windows.Media.Color class.

# Changes the background color for the error text that appears in the Output Pane to black. 
$psISE.Options.ErrorBackgroundColor="black"

ErrorForegroundColor

Read/write property that gets or sets the foreground color for the error text that appears in the Output Pane. It is an instance of the System.Windows.Media.Color class.

# Changes the foreground color for the error text that appears in the Output Pane to green. 
$psISE.Options.ErrorForegroundColor =”green”

FontName

Read/write property that gets or sets the font name currently in use in the Script Pane, Command Pane and the Output Pane.

# Changes the font used in all the panes. 
$psISE.Options.FontName = "courier new"

FontSize

Read/write property that gets or sets the font size (an integer) used in the Script Pane, Command Pane and the Output Pane. The valid range of values is (8, 32).

# Changes the font size in all the panes.
$psISE.Options.FontSize = 20

OutputPaneBackgroundColor

Read/write property that gets or sets the background color for the Output Pane itself. It is an instance of the System.Windows.Media.Color class.

# Changes the background color of the Output Pane to gold. 
$psISE.Options.OutputPaneForegroundColor = "gold"

OutputPaneTextForegroundColor

Read/write property that changes the foreground color of the text in the Output Pane.

# Changes the foreground color of the text in the Output Pane to blue.
$psISE.Options.OutputPaneTextForegroundColor  = "blue"

OutputPaneTextBackgroundColor

Read/write property that changes the background color of the text in the Output Pane.

# Changes the background color of the Output Pane text to pink. 
$psISE.Options.OutputPaneTextBackgroundColor = "pink"

ScriptPaneBackgroundColor

Read/write property that gets or sets the background color for files. It is an instance of the System.Windows.Media.Color class.

 
# Sets the color of the script pane background to yellow.
$psISE.Options.ScriptPaneBackgroundColor = ”yellow”

ScriptPaneForegroundColor

Read/Write property that gets or sets the foreground color for non-script files in the script pane. To set the foreground color for script files use the TokenColors property.

# Sets the foreground to color of non-script files in the script pane to green.
$psISE.Options.ScriptPaneBackgroundColor = ”green”

SelectedScriptPaneState

Read/write property that gets or sets the position of the Script Pane on the display. The possible values are “top”, “right”, and “Maximized”.

# Moves the Script Pane to the top
$psISE.Options.SelectedScriptPaneState = "Top"
# Moves the Script Pane to the right.
$psISE.Options.SelectedScriptPaneState = "Right"
# Maximizes the Script Pane
$psISE.Options.SelectedScriptPaneState = "Maximized"

ShowToolBar

Read/write Boolean property that determines whether the tool bar is visible.

# Show the tool bar.
$psISe.Options.ShowToolBar = $true

ShowWarningBeforeSavingOnRun

Read/write property that gets or sets a Boolean value that determines whether a warning message is displayed when a script is saved automatically before it is run.

# Sets the option to display a warning message 
# when an attempt is made to save a script before running it.
$psISE.Options.ShowWarningBeforeSavingOnRun=$true   

ShowWarningForDuplicateFiles

Read/write property that gets or sets a Boolean value that causes a warning message to appear when the same file is opened in different PowerShell tabs.

# Set the ShowWarningForDuplicateFiles property to true. 
$psISE.Options.ShowWarningForDuplicateFiles = $true
# The following  message is displayed: “A copy of this file
# is open in another PowerShell Tab. Changes made to this
# file will affect all open copies.”

TokenColors

A property that gets a dictionary object that contains name/value pairs of token types and colors for the Command Pane and the Script Pane.

# Sets the color of commands to green.
$psISE.Options.TokenColors["Command"] = "green"
# Sets the color of keywords to magenta.
$psISE.Options.TokenColors["Keyword"] = "magenta"

UseLocalHelp

Read/write property that gets or sets a Boolean value that indicates whether the local help or the online help is displayed.

# Sets the option for the online help to be displayed. 
$psISE.Options.LocalHelp=$false

VerboseBackgroundColor

Read/write property that gets or sets the background color for the verbose text that appears in the Output Pane. It is a System.Windows.Media.Color Object.

# Changes the background color for the verbose text that appears in the Output Pane to blue. 
$psISE.Options.VerboseBackgroundColor ='#0000FF'

VerboseForegroundColor

Read/write property that gets or sets the foreground color for the verbose text that appears in the Output Pane. It is a System.Windows.Media.Color Object.

# Changes the foreground color for the verbose text that appears in the Output Pane to yellow. 
$psISE.Options.VerboseForegroundColor =”yellow”

WarningBackgroundColor

Read/write property that gets or sets the background color for the warning text that appears in the Output Pane. It is a System.Windows.Media.Color Object.

# Changes the background color for the warning text that appears in the Output Pane to blue. 
$psISE.Options.WarningBackgroundColor ='#0000FF'

WarningForegroundColor

Read/write property that gets or sets the foreground color for the warning text that appears in the Output Pane. It is a System.Windows.Media.Color Object.

# Changes the foreground color for the warning text that appears in the Output Pane to yellow. 
$psISE.Options.WarningForegroundColor =”yellow”

See Also




Table Of Contents