Options 对象表示 Windows PowerShell ISE 的多种设置。它是 Microsoft.PowerShell.Host.ISE.ISEOptions 类的一个实例。

方法

RestoreDefaultTokenColors()

还原标记颜色的默认值。

# 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()

还原所有选项设置的默认值。此方法还可重置用于提供“不再显示此消息”标准复选框的各种警告消息的行为。

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

属性

CommandPaneBackgroundColor

读/写属性,用于获取或设置命令窗格编辑器的背景色。它是 System.Windows.Media.Color 类的一个实例。

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

CommandPaneUp

读/写属性,用于获取或设置指示命令窗格是否位于输出窗格上面的布尔值。

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

DebugBackgroundColor

读/写属性,用于获取或设置输出窗格中所显示的调试文本的背景色。它是 System.Windows.Media.Color 类的一个实例。

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

DebugForegroundColor

读/写属性,用于获取或设置输出窗格中所显示的调试文本的前景色。它是 System.Windows.Media.Color 类的一个实例。

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

DefaultOptions

只读属性,用于获取选项设置的默认值。

# 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

读/写属性,用于获取或设置输出窗格中所显示的错误文本的背景色。它是 System.Windows.Media.Color 类的一个实例。

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

ErrorForegroundColor

读/写属性,用于获取或设置输出窗格中所显示的错误文本的前景色。它是 System.Windows.Media.Color 类的一个实例。

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

FontName

读/写属性,用于获取或设置脚本窗格、命令窗格和输出窗格中当前使用的字体名称。

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

FontSize

读/写属性,用于获取或设置脚本窗格、命令窗格和输出窗格中使用的字体大小(整数)。值的有效范围是 (8, 32)。

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

OutputPaneBackgroundColor

读/写属性,用于获取或设置输出窗格本身的背景色。它是 System.Windows.Media.Color 类的一个实例。

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

OutputPaneTextForegroundColor

读/写属性,用于更改输出窗格中文本的前景色。

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

OutputPaneTextBackgroundColor

读/写属性,用于更改输出窗格中文本的背景色。

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

ScriptPaneBackgroundColor

读/写属性,用于获取或设置文件的背景色。它是 System.Windows.Media.Color 类的一个实例。

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

ScriptPaneForegroundColor

读/写属性,用于获取或设置脚本窗格中非脚本文件的前景色。若要设置脚本文件的前景色,请使用 TokenColors 属性。

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

SelectedScriptPaneState

读/写属性,用于获取或设置脚本窗格在显示屏上的位置。可能的值包括“top”、“right”和“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

布尔型的读/写属性,用于确定工具栏是否可见。

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

ShowWarningBeforeSavingOnRun

用于获取或设置布尔值的读/写属性,该布尔值确定在运行脚本之前自动保存脚本时是否显示警告消息。

# 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

用于获取或设置布尔值的读/写属性,该布尔值使得在不同的 PowerShell 选项卡中打开相同文件时显示警告消息。

# 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

用于获取字典对象的属性,该对象包含命令窗格和脚本窗格的标记类型和颜色的名称/值对。

# 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

用于获取或设置布尔值的读/写属性,该布尔值可指示显示本地帮助还是联机帮助。

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

VerboseBackgroundColor

读/写属性,用于获取或设置输出窗格中所显示的详细文本的背景色。该属性是 System.Windows.Media.Color 对象。

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

VerboseForegroundColor

读/写属性,用于获取或设置输出窗格中所显示的详细文本的前景色。该属性是 System.Windows.Media.Color 对象。

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

WarningBackgroundColor

读/写属性,用于获取或设置输出窗格中所显示的警告文本的背景色。该属性是 System.Windows.Media.Color 对象。

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

WarningForegroundColor

读/写属性,用于获取或设置输出窗格中所显示的警告文本的前景色。该属性是 System.Windows.Media.Color 对象。

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

另请参阅




目录