ISEOptions 对象表示 Windows PowerShell ISE 的各种设置。 它是 Microsoft.PowerShell.Host.ISE.ISEOptions 类的 实例。
ISEOptions 对象提供以下方法和属性。
方法
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()
性能
AutoSaveMinuteInterval
在 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
CommandPaneBackgroundColor
此功能存在于 Windows PowerShell ISE 2.0 中,但在更高版本的 ISE 中删除或重命名。 有关更高版本,请参阅 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 中,但在更高版本的 ISE 中删除或重命名。
指定命令窗格是否位于“输出”窗格上方。
# Moves the Command pane to the top of the screen.
$psISE.Options.CommandPaneUp = $true
ConsolePaneBackgroundColor
在 Windows PowerShell ISE 3.0 及更高版本中受支持,在早期版本中不存在。
指定控制台窗格的背景色。 它是 System.Windows.Media.Color 类的实例。
# Changes the background color of the Console pane to red.
$psISE.Options.ConsolePaneBackgroundColor = 'red'
ConsolePaneForegroundColor
在 Windows PowerShell ISE 3.0 及更高版本中受支持,在早期版本中不存在。
指定控制台窗格中文本的前景色。
# Changes the foreground color of the text in the Console pane to yellow.
$psISE.Options.ConsolePaneForegroundColor = 'yellow'
ConsolePaneTextBackgroundColor
在 Windows PowerShell ISE 3.0 及更高版本中受支持,在早期版本中不存在。
指定控制台窗格中文本的背景色。
# Changes the background color of the Console pane text to pink.
$psISE.Options.ConsolePaneTextBackgroundColor = 'pink'
ConsoleTokenColors
在 Windows PowerShell ISE 3.0 及更高版本中受支持,在早期版本中不存在。
指定 Windows PowerShell ISE 控制台窗格中 IntelliSense 令牌的颜色。 此属性是一个字典对象,其中包含控制台窗格的标记类型和颜色的名称/值对。 若要在“脚本”窗格中更改 IntelliSense 令牌的颜色,请参阅 TokenColors。 若要将颜色重置为默认值,请参阅 RestoreDefaultConsoleTokenColors。 可以为以下项设置标记颜色:Attribute
、、Command
、CommandArgument
、CommandParameter
、Keyword
GroupStart
GroupEnd
LoopLabel
NewLine
Number
Comment
Operator
Member
LineContinuation
、。 Position
StatementSeparator
String
Type
Unknown
Variable
# Sets the color of commands to green.
$psISE.Options.ConsoleTokenColors["Command"] = 'green'
# Sets the color of keywords to magenta.
$psISE.Options.ConsoleTokenColors["Keyword"] = 'magenta'
DebugBackgroundColor
在 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'
DebugForegroundColor
在 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'
DefaultOptions
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
一个属性集合,指定使用 Reset 方法时要使用的默认值。
# 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
ErrorBackgroundColor
在 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'
ErrorForegroundColor
在 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'
字体名称
在 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
IntellisenseTimeoutInSeconds
在 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
OutputPaneBackgroundColor
此功能存在于 Windows PowerShell ISE 2.0 中,但在更高版本的 ISE 中删除或重命名。 有关更高版本,请参阅 ConsolePaneBackgroundColor。
可获取或设置“输出”窗格本身的背景色的读/写属性。 它是 System.Windows.Media.Color 类的实例。
# Changes the background color of the Output pane to gold.
$psISE.Options.OutputPaneForegroundColor = 'gold'
OutputPaneTextForegroundColor
此功能存在于 Windows PowerShell ISE 2.0 中,但在更高版本的 ISE 中删除或重命名。 有关更高版本,请参阅 ConsolePaneForegroundColor。
更改 Windows PowerShell ISE 2.0 中“输出”窗格中文本的前景色的读/写属性。
# Changes the foreground color of the text in the Output Pane to blue.
$psISE.Options.OutputPaneTextForegroundColor = 'blue'
OutputPaneTextBackgroundColor
此功能存在于 Windows PowerShell ISE 2.0 中,但在更高版本的 ISE 中删除或重命名。 有关更高版本,请参阅 ConsolePaneTextBackgroundColor。
更改“输出”窗格中文本的背景色的读/写属性。
# Changes the background color of the Output pane text to pink.
$psISE.Options.OutputPaneTextBackgroundColor = 'pink'
ScriptPaneBackgroundColor
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
可获取或设置文件的背景色的读/写属性。 它是 System.Windows.Media.Color 类的实例。
# Sets the color of the script pane background to yellow.
$psISE.Options.ScriptPaneBackgroundColor = 'yellow'
ScriptPaneForegroundColor
在 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 及更高版本中受支持。
可获取或设置显示上“脚本”窗格位置的读/写属性。 字符串可以是“最大化”、“Top”或“Right”。
# 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
ShowOutlining
在 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
ShowWarningBeforeSavingOnRun
在 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
ShowWarningForDuplicateFiles
在 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
TokenColors
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
指定 Windows PowerShell ISE 脚本窗格中 IntelliSense 令牌的颜色。 此属性是一个字典对象,其中包含脚本窗格的标记类型和颜色的名称/值对。 若要更改控制台窗格中 IntelliSense 令牌的颜色,请参阅 ConsoleTokenColors。 若要将颜色重置为默认值,请参阅 RestoreDefaultTokenColors。 可以为以下内容设置标记颜色:Attribute、Command、CommandArgument、CommandParameter、Comment、GroupEnd、GroupStart、Keyword、LineContinuation、LoopLabel、Member、NewLine、Number、Operator、Position、StatementSeparator、String、Type、Unknown、Variable。
# 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 及更高版本中受支持,在早期版本中不存在。
指定是否可以使用 Enter 键在控制台窗格中选择 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 及更高版本中受支持,在早期版本中不存在。
指定是否可以使用 Enter 键在脚本窗格中选择 IntelliSense 提供的选项。 默认值为 $true
。
# Turn on using the Enter key to select an IntelliSense provided option in the Console pane.
$psISE.Options.UseEnterToSelectInConsolePaneIntellisense = $true
UseLocalHelp
在 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
VerboseBackgroundColor
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
指定在控制台窗格中显示的详细文本的背景色。 它是 System.Windows.Media.Color 对象。
# Changes the background color for verbose text to blue.
$psISE.Options.VerboseBackgroundColor ='#0000FF'
VerboseForegroundColor
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
指定在控制台窗格中显示的详细文本的前景色。 它是 System.Windows.Media.Color 对象。
# Changes the foreground color for verbose text to yellow.
$psISE.Options.VerboseForegroundColor = 'yellow'
WarningBackgroundColor
在 Windows PowerShell ISE 2.0 及更高版本中受支持。
指定在控制台窗格中显示的警告文本的背景色。 它是 System.Windows.Media.Color 对象。
# Changes the background color for warning text to blue.
$psISE.Options.WarningBackgroundColor = '#0000FF'
WarningForegroundColor
在 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 及更高版本中受支持,在早期版本中不存在。
指定一个字典对象,该对象包含 Windows PowerShell ISE 中显示的 XML 内容的标记类型和颜色的名称/值对。 可以为以下内容设置标记颜色:Attribute、Command、CommandArgument、CommandParameter、Comment、GroupEnd、GroupStart、Keyword、LineContinuation、LoopLabel、Member、NewLine、Number、Operator、Position、StatementSeparator、String、Type、Unknown、Variable。 另请参阅 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
另请参阅
- Windows PowerShell ISE 脚本对象模型的 用途
- ISE 对象模型层次结构