ISEOptions 对象

ISEOptions 对象代表了 Windows PowerShell ISE 的各种设置。 它是 Microsoft.PowerShell.Host.ISE.ISEOptions 类的一个实例。

ISEOptions 对象提供了以下方法和属性。

Methods

RestoreDefaultConsoleTokenColors()

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

恢复控制台面板中代币颜色的默认值。

# Changes the color of the commands in the Console pane to red and then restores
# it to its default value.
$psISE.Options.ConsoleTokenColors["Command"] = 'red'
$psISE.Options.RestoreDefaultConsoleTokenColors()

RestoreDefaults()

支持Windows PowerShell ISE 2.0及更高版本。

恢复控制台面板中所有选项设置的默认值。 它还会重置各种警告消息的行为,这些警告消息提供了标准的复选框,以防止该消息再次显示。

# Changes the background color in the Console pane and then restores it to its default value.
$psISE.Options.ConsolePaneBackgroundColor = 'orange'
$psISE.Options.RestoreDefaults()

RestoreDefaultTokenColors()

支持Windows PowerShell ISE 2.0及更高版本。

恢复脚本面板中令牌颜色的默认值。

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

RestoreDefaultXmlTokenColors()

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

恢复 Windows PowerShell ISE 中显示的 XML 元素令牌颜色的默认值。 另见 XmlTokenColors

# Changes the color of the comments in XML data to red and then restores it
# to its default value.
$psISE.Options.XmlTokenColors["Comment"] = 'red'
$psISE.Options.RestoreDefaultXmlTokenColors()

属性

自动保存分钟间隔

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

通过 Windows PowerShell ISE 指定文件自动保存作之间的分钟数。 默认数值是2分钟。 该值为整数。

# Changes the number of minutes between automatic save operations to every 3 minutes.
$psISE.Options.AutoSaveMinuteInterval = 3

命令面板背景颜色

该功能存在于 Windows PowerShell ISE 2.0 中,但在后续版本中被移除或重命名。 有关后续版本,请参见 ConsolePaneBackgroundColor

指定命令面板的背景色。 它是 System.Windows.Media.Color 类的一个实例。

# Changes the background color of the Command pane to orange.
$psISE.Options.CommandPaneBackgroundColor = 'orange'

CommandPaneUp

该功能存在于 Windows PowerShell ISE 2.0 中,但在后续版本中被移除或重命名。

指定命令面板是否位于输出面板之上。

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

控制台面板背景颜色

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定控制台面板的背景色。 它是 System.Windows.Media.Color 类的一个实例。

# Changes the background color of the Console pane to red.
$psISE.Options.ConsolePaneBackgroundColor = 'red'

控制台面板前景颜色

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定控制台面板中文本的前景颜色。

# Changes the foreground color of the text in the Console pane to yellow.
$psISE.Options.ConsolePaneForegroundColor  = 'yellow'

控制台面板文本背景颜色

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定控制台面板中文本的背景颜色。

# Changes the background color of the Console pane text to pink.
$psISE.Options.ConsolePaneTextBackgroundColor = 'pink'

控制台代币颜色

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定 Windows PowerShell ISE 控制台面板中 IntelliSense 令牌的颜色。 该属性是一个字典对象,包含控制台面板中标记类型和颜色的名称/值对。 要在脚本面板中更改 IntelliSense 令牌的颜色,请参见 TokenColors。 要将颜色重置为默认值,请参见 RestoreDefaultConsoleTokenColors。 标记颜色可以设置为以下Attribute:, CommandCommandArgumentCommandParameterCommentGroupEndGroupStartKeywordLineContinuationLoopLabelMemberNewLineNumberOperatorPositionStatementSeparatorStringTypeUnknownVariable

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

调试背景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中出现的调试文本的背景色。 它是 System.Windows.Media.Color 类的一个实例。

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

调试前景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中调试文本的前景颜色。 它是 System.Windows.Media.Color 类的一个实例。

# Changes the foreground color for the debug text that appears in the Console
# pane to yellow.
$psISE.Options.DebugForegroundColor = 'yellow'

默认选项

支持Windows PowerShell ISE 2.0及更高版本。

一组属性,指定在使用重置方法时应使用的默认值。

# Displays the name of the default options. This example is from ISE 4.0.
$psISE.Options.DefaultOptions
SelectedScriptPaneState                   : Top
ShowDefaultSnippets                       : True
ShowToolBar                               : True
ShowOutlining                             : True
ShowLineNumbers                           : True
TokenColors                               : {[Attribute, #FF00BFFF], [Command, #FF0000FF],
                                            [CommandArgument, #FF8A2BE2], [CommandParameter, #FF000080]...}
ConsoleTokenColors                        : {[Attribute, #FFB0C4DE], [Command, #FFE0FFFF],
                                            [CommandArgument, #FFEE82EE], [CommandParameter, #FFFFE4B5]...}
XmlTokenColors                            : {[Comment, #FF006400], [CommentDelimiter, #FF008000],
                                            [ElementName, #FF8B0000], [MarkupExtension, #FFFF8C00]...}
DefaultOptions                            : Microsoft.PowerShell.Host.ISE.ISEOptions
FontSize                                  : 9
Zoom                                      : 100
FontName                                  : Lucida Console
ErrorForegroundColor                      : #FFFF9494
ErrorBackgroundColor                      : #00FFFFFF
WarningForegroundColor                    : #FFFF8C00
WarningBackgroundColor                    : #00FFFFFF
VerboseForegroundColor                    : #FF00FFFF
VerboseBackgroundColor                    : #00FFFFFF
DebugForegroundColor                      : #FF00FFFF
DebugBackgroundColor                      : #00FFFFFF
ConsolePaneBackgroundColor                : #FF012456
ConsolePaneTextBackgroundColor            : #FF012456
ConsolePaneForegroundColor                : #FFF5F5F5
ScriptPaneBackgroundColor                 : #FFFFFFFF
ScriptPaneForegroundColor                 : #FF000000
ShowWarningForDuplicateFiles              : True
ShowWarningBeforeSavingOnRun              : True
UseLocalHelp                              : True
AutoSaveMinuteInterval                    : 2
MruCount                                  : 10
ShowIntellisenseInConsolePane             : True
ShowIntellisenseInScriptPane              : True
UseEnterToSelectInConsolePaneIntellisense : True
UseEnterToSelectInScriptPaneIntellisense  : True

错误背景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中错误文本的背景颜色。 它是 System.Windows.Media.Color 类的一个实例。

# Changes the background color for the error text that appears in the Console pane to black.
$psISE.Options.ErrorBackgroundColor = 'black'

错误前景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中错误文本的前景颜色。 它是 System.Windows.Media.Color 类的一个实例。

# Changes the foreground color for the error text that appears in the console pane to green.
$psISE.Options.ErrorForegroundColor = 'green'

FontName

支持Windows PowerShell ISE 2.0及更高版本。

指定当前在脚本面板和控制台面板中使用的字体名称。

# Changes the font used in both panes.
$psISE.Options.FontName = 'Courier New'

字体大小

支持Windows PowerShell ISE 2.0及更高版本。

以整数表示字体大小。 它被用于脚本面板、命令面板和输出面板。 有效值范围为8至32。

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

智力感知超时秒数

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定 IntelliSense 用来解析当前输入文本所需的秒数。 经过这段时间,IntelliSense 超时,允许你继续输入。 默认数值是3秒。 该值为整数。

# Changes the number of seconds for IntelliSense syntax recognition to 5.
$psISE.Options.IntellisenseTimeoutInSeconds = 5

MruCount

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定 Windows PowerShell ISE 在“ 文件打开 ”菜单底部跟踪并显示最近打开的文件数量。 默认值为 10。 该值为整数。

# Changes the number of recently used files that appear at the bottom of the
# File Open menu to 5.
$psISE.Options.MruCount = 5

输出窗格背景颜色

该功能存在于 Windows PowerShell ISE 2.0 中,但在后续版本中被移除或重命名。 有关后续版本,请参见 ConsolePaneBackgroundColor

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

# Changes the background color of the Output pane to gold.
$psISE.Options.OutputPaneForegroundColor = 'gold'

输出面板文本前景颜色

该功能存在于 Windows PowerShell ISE 2.0 中,但在后续版本中被移除或重命名。 关于后续版本,请参见 ConsolePaneForegroundColor

在 Windows PowerShell ISE 2.0 中,可以更改输出面板中文本前景颜色的读写属性。

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

输出面板文本背景颜色

该功能存在于 Windows PowerShell ISE 2.0 中,但在后续版本中被移除或重命名。 关于后续版本,请参见 ConsolePaneTextBackgroundColor

读取/写入属性,可以改变输出面板中文本的背景颜色。

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

脚本面板背景颜色

支持Windows PowerShell ISE 2.0及更高版本。

就是读取/写入文件背景颜色的属性。 它是 System.Windows.Media.Color 类的一个实例。

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

脚本面板前景颜色

支持Windows PowerShell ISE 2.0及更高版本。

读写属性,用于在脚本面板中为非脚本文件设置前景颜色。 要设置脚本文件的前景颜色,可以使用 TokenColors

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

SelectedScriptPaneState

支持Windows PowerShell ISE 2.0及更高版本。

读取/写入属性,用于获取或设置脚本面板在显示器上的位置。 字符串可以是“最大化”、“顶端”或“右”。

# 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'

ShowDefaultSnippets

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定 Ctrl+J 的片段列表是否包含 Windows PowerShell 中包含的起始集。 当设置为 $false时,只有用户自定义的片段会出现在 Ctrl+J 列表中。 默认值为 $true

# Hide the default snippets from the Ctrl+J list.
$psISE.Options.ShowDefaultSnippets = $false

ShowIntellisenseInConsolePane

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定IntelliSense是否在控制台面板中提供语法、参数和值建议。 默认值为 $true

# Turn off IntelliSense in the console pane.
$psISE.Options.ShowIntellisenseInConsolePane = $false

ShowIntellisenseInScriptPane

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定 IntelliSense 是否在脚本面板中提供语法、参数和值建议。 默认值为 $true

# Turn off IntelliSense in the Script pane.
$psISE.Options.ShowIntellisenseInScriptPane = $false

ShowLineNumbers(展示线数)

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定脚本面板是否在左边框显示行号。 默认值为 $true

# Turn off line numbers in the Script pane.
$psISE.Options.ShowLineNumbers = $false

节目大纲

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定脚本面板左边框代码区块旁是否显示可展开和可折叠括号。 显示时,你可以点击文本块旁的减 - 号图标将其折叠,或者点击加号 + 图标展开一段文字。 默认值为 $true

# Turn off outlining in the Script pane.
$psISE.Options.ShowOutlining = $false

ShowToolBar

支持Windows PowerShell ISE 2.0及更高版本。

指定 ISE 工具栏是否出现在 Windows PowerShell ISE 窗口顶部。 默认值为 $true

# Show the toolbar.
$psISE.Options.ShowToolBar = $true

在保存之前请先警告

支持Windows PowerShell ISE 2.0及更高版本。

指定在脚本运行前自动保存时是否会弹出警告信息。 默认值为 $true

# Enable the warning message when an attempt
# is made to run a script without saving it first.
$psISE.Options.ShowWarningBeforeSavingOnRun = $true

重复文件警告显示

支持Windows PowerShell ISE 2.0及更高版本。

指定在不同 PowerShell 标签页中打开相同文件时是否会出现警告信息。 如果设置为 $true,则在多个标签页中打开同一个文件会显示以下信息:“该文件的副本在另一个 Windows PowerShell 标签页中打开。对该文件所做的更改将影响所有打开的副本。”默认值为 $true

# Enable the warning message when a file is
# opened in multiple PowerShell tabs.
$psISE.Options.ShowWarningForDuplicateFiles = $true

代币颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定 Windows PowerShell ISE 脚本面板中 IntelliSense 令牌的颜色。 该属性是一个字典对象,包含脚本面板中标记类型和颜色的名称/值对。 要在控制台面板中更改 IntelliSense 代币的颜色,请参见 ConsoleTokenColors。 要将颜色重置为默认值,请参见 RestoreDefaultTokenColors。 标记颜色可以设置为以下:属性、命令、命令参数、命令参数、注释、组结束、组起始、关键词、行续写、循环标签、成员、换行、数字、运算符、位置、语句分隔符、字符串、类型、未知、变量。

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

UseEnterToSelectInConsolePaneIntellisense

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

说明是否可以使用回车键在控制台面板中选择IntelliSense提供的选项。 默认值为 $true

# Turn off using the ENTER key to select an IntelliSense provided option in the Console pane.
$psISE.Options.UseEnterToSelectInConsolePaneIntellisense = $false

UseEnterToSelectInScriptPaneIntellisense

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

说明您是否可以使用回车键在脚本面板中选择IntelliSense提供的选项。 默认值为 $true

# Turn on using the Enter key to select an IntelliSense provided option in the Console pane.
$psISE.Options.UseEnterToSelectInConsolePaneIntellisense = $true

使用LocalHelp。

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定当你按 F1 并将光标置在关键词时,是本地安装的帮助还是在线帮助。 如果设置为 $true,则弹出窗口显示本地安装的帮助内容。 你可以通过运行 Update-Help 命令安装帮助文件。 如果设置为 $false,浏览器会打开 Microsoft Learn 页面。

# Sets the option for the online help to be displayed.
$psISE.Options.UseLocalHelp = $false
# Sets the option for the local Help to be displayed.
$psISE.Options.UseLocalHelp = $true

冗长背景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中冗长文本的背景色。 它是一个 System.Windows.Media.Color 对象。

# Changes the background color for verbose text to blue.
$psISE.Options.VerboseBackgroundColor ='#0000FF'

冗长前景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中冗长文本的前景颜色。 它是一个 System.Windows.Media.Color 对象。

# Changes the foreground color for verbose text to yellow.
$psISE.Options.VerboseForegroundColor = 'yellow'

警告背景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定控制台面板中警告文本的背景颜色。 它是一个 System.Windows.Media.Color 对象。

# Changes the background color for warning text to blue.
$psISE.Options.WarningBackgroundColor = '#0000FF'

警告:前景颜色

支持Windows PowerShell ISE 2.0及更高版本。

指定输出面板中出现的警告文本的前景颜色。 它是一个 System.Windows.Media.Color 对象。

# Changes the foreground color for warning text to yellow.
$psISE.Options.WarningForegroundColor = 'yellow'

XmlTokenColors

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定一个字典对象,包含XML内容的名称/值对、令牌类型和颜色,这些内容在Windows、PowerShell ISE中显示。 标记颜色可以设置为以下:属性、命令、命令参数、命令参数、注释、组结束、组起始、关键词、行续写、循环标签、成员、换行、数字、运算符、位置、语句分隔符、字符串、类型、未知、变量。 另见 RestoreDefaultXmlTokenColors

# Sets the color of XML element names to green.
$psISE.Options.XmlTokenColors["ElementName"] = 'green'
# Sets the color of XML comments to magenta.
$psISE.Options.XmlTokenColors["Comment"] = 'magenta'

缩放

Windows PowerShell ISE 3.0及以后版本支持,早期版本中不支持。

指定控制台和脚本面板中文本的相对大小。 默认值为 100。 值越小,Windows PowerShell ISE中的文本看起来越小,数字越大,文本越大。 该数值为整数,范围为20到400。

# Changes the text in the Windows PowerShell ISE to be double its normal size.
$psISE.Options.Zoom = 200

另请参阅