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
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
控制台面板背景顏色
支援於 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'
ConsoleTokenColors
支援於 Windows PowerShell ISE 3.0 及以上版本,且早期版本中不存在此功能。
指定 Windows PowerShell ISE 主控台窗格中 IntelliSense 標記的顏色。 這個屬性是一個字典物件,包含主控台窗格中標記類型和顏色的名稱/值對。 若要在腳本窗格中更改 IntelliSense 標記的顏色,請參見 TokenColors。 要將顏色重設為預設值,請參見 RestoreDefaultConsoleTokenColors。 代幣顏色可設定為以下Attribute:、Command、CommandArgument、CommandParameterCommentGroupEndGroupStartKeywordLineContinuationLoopLabelMemberNewLineNumberOperatorPositionStatementSeparatorStringTypeUnknownVariable。
# 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 中,但在後續版本的 ISE 中被移除或重新命名。 關於後續版本,請參見 ConsolePaneBackgroundColor。
讀取/寫入屬性,負責取得或設定輸出窗格本身的背景顏色。 它是 System.Windows.Media.Color 類別的實例。
# Changes the background color of the Output pane to gold.
$psISE.Options.OutputPaneForegroundColor = 'gold'
輸出面板文字前景顏色
此功能存在於 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'
輸出PaneTextBackgroundColor
此功能存在於 Windows PowerShell ISE 2.0 中,但在後續版本的 ISE 中被移除或重新命名。 後續版本請參見 ConsolePaneTextBackgroundColor。
讀取/寫入屬性,會改變輸出窗格中文字的背景顏色。
# Changes the background color of the Output pane text to pink.
$psISE.Options.OutputPaneTextBackgroundColor = 'pink'
ScriptPane背景顏色
支援於 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 及以上版本,且早期版本中不存在此功能。
指定 Script 面板是否在左邊框顯示行號。 預設值是 $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
ShowWarningBeforeSave OnRun
支援於 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 標記的顏色。 此屬性是一個字典物件,包含 Script 窗格中標記類型與顏色的名稱/值對。 要在控制台面板中更改 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 及以上版本,且早期版本中不存在此功能。
指定是否能使用 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
使用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