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”

請參閱




目錄