An ISEMenuItem object is an instance of the Microsoft.PowerShell.Host.ISE.ISEMenuItem class. All menu objects on the Add-ons menu are members of the Microsoft.PowerShell.Host.ISE.ISEMenuItem class.

Properties

DisplayName

Read-only property that gets the name of the menu.

# 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

Action

Read-only property that gets the script (block) to be invoked when the menu item is clicked.

# 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 (Note the “.” At the beginning of the command).
# Invoke the action
$psISE.CurrentPowerShellTab.AddOnsMenu.Submenus[0].Action.Invoke()

Shortcut

Read-only property that gets the Windows input key gesture for the menu item.

# 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

Submenus

Read-only property that gets the list of submenus of the menu item.

# 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

Scripting example

To better understand the use of the Add-ons menu and its scriptable properties, read through the following scripting example:

# This is a scripting example that shows the use of the Add-ons menu.
# Clear the Add-ons menu if one exists
$psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Clear()
# Add an Add-ons menu with an accessor.
# Note the use of “_”  as opposed to the “&” for mapping to the fast key letter for the menu item.
$menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Process",{get-process},"Alt+P") 
# Add a nested menu. 
$parentAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("Parent",$null,$null) 
$parentAdded.SubMenus.Add("_Dir",{dir},"Ctrl+Shift+D")

See Also




Table Of Contents