ISEMenuItem-objektet
Ett ISEMenuItem-objekt är en instans av klassen Microsoft.PowerShell.Host.ISE.ISEMenuItem . Alla menyobjekt på tilläggsmenyn är instanser av klassen Microsoft.PowerShell.Host.ISE.ISEMenuItem .
Egenskaper
DisplayName
Stöds i Windows PowerShell ISE 2.0 och senare.
Den skrivskyddade egenskapen som hämtar visningsnamnet för menyalternativet.
# Get the display name of the Add-ons menu item
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('_Process', {Get-Process}, 'Alt+P')
$psISE.CurrentPowerShellTab.AddOnsMenu.DisplayName
Åtgärd
Stöds i Windows PowerShell ISE 2.0 och senare.
Den skrivskyddade egenskapen som hämtar skriptblocket. Den anropar åtgärden när du klickar på menyalternativet.
# Get the action associated with the first submenu item.
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('_Process', {Get-Process}, 'Alt+P')
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action
# Invoke the script associated with the first submenu item
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action.Invoke()
Genväg
Stöds i Windows PowerShell ISE 2.0 och senare.
Den skrivskyddade egenskapen som hämtar kortkommandot för Windows-indata för menyalternativet.
# Get the shortcut for the first submenu item.
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('_Process', {Get-Process}, 'Alt+P')
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Shortcut
Undermenyer
Stöds i Windows PowerShell ISE 2.0 och senare.
Den skrivskyddade egenskapen som hämtar listan över undermenyer för menyalternativet.
# List the submenus of the Add-ons menu
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('_Process', {Get-Process}, 'Alt+P')
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus
Skriptexempel
Läs igenom följande skriptexempel för att bättre förstå användningen av tilläggsmenyn och dess skriptbara egenskaper.
# This is a scripting example that shows the use of the Add-ons menu.
# Clear the Add-ons menu if any entries currently exist
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Clear()
# Add an Add-ons menu item with an shortcut and fast access key.
# Note the use of "_" as opposed to the "&" for mapping to the fast access key letter for the menu item.
$menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add('_Process', {Get-Process}, 'Alt+P')
# Add a nested menu - a parent and a child submenu item.
$parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.Submenus.Add('Parent', $null, $null)
$parentAdded.SubMenus.Add('_Dir', {dir}, 'Alt+D')