Add-ISEMenu

Add-ISEMenu is helper function to add menus to the ISE. This makes adding menus to the Windows PowerShell Integrated Scripting Environment (ISE)easier. Add-IseMenu accepts a hashtable of menus. Each key is the name of the menu. There keys are automatically alphabetized, unless the
Each value can be one of three things:
- A Script Block
Selecting the menu item will run the script block
- A Hashtable
The value will be used to create a nested menu
- A Script Block with a note property of ShortcutKey
Selecting the menu item will run the script block.
The ShortcutKey will be used to assign a shortcut key to the item
Example 1:
Add-IseMenu -Name "Get" @{
"Process" = { Get-Process }
"Service" = { Get-Service }
"Hotfix" = {Get-Hotfix}
}
Example 2:
Add-IseMenu -Name "Verb" @{
Get = @{
Process = { Get-Process }
Service = { Get-Service }
Hotfix = { Get-Hotfix }
}
Import = @{
Module = { Import-Module }
}
}
Example 3:
Add-IseMenu -Name "Favorites" @{
"Edit Profile" = { psedit $profile } |
Add-Member NoteProperty ShortcutKey "CTRL + E" -PassThru
}
Example 4:
Add-IseMenu -Name "Get2" @{
"Process" = { Get-Process } | Add-Member NoteProperty order 2 -PassThru
"Service" = { Get-Service } | Add-Member NoteProperty order 1 -PassThru
"Hotfix" = {Get-Hotfix} | Add-Member NoteProperty order 3 -PassThru | Add-Member NoteProperty ShortcutKey "CTRL ALTB" -PassThru
}
Example 5:
Add-IseMenu -name SQLIse @{
"Connection" =@{
"Connect..." = {Connect-Sql}
"Disconnect" = {Disconnect-Sql}
}
"Execute" = {Invoke-ExecuteSql} | Add-Member NoteProperty ShortcutKey "CTRLALTF5" -PassThru
} -module SQLIse
Add-IseMenu -name OracleIse @{
"Connection" =@{
"Connect..." = {Connect-Sql}
"Disconnect" = {Disconnect-Sql}
}
"Execute" = {Invoke-ExecuteSql} | Add-Member NoteProperty ShortcutKey "CTRLALTF5" -PassThru
} -module OracleIse

Both modules define functions with the same name. The module parameter invokes the function from module context. OracleIse Execute will be created without the Shortcut-Key which is allready in use.

Remove-ISEMenu
This is helper function to remove menus from ISE addon menu. Remove Menu specified by name from the current tab, or a tab specified by Displayname or index.

Example 1:
Remove-IseMenu -Name Edit
Remove the Edit menu from the current tab
Example 2:
Remove-IseMenu Edit
Remove the Edit menu from the current tab (Same as above using position)
Example 3:
Remove-IseMenu Edit -tab 1
Remove the Edit menu from the 2nd tab (if you count the human way)
Example 4:
Remove-IseMenu Edit 1
Remove the Edit menu from the 2nd tab (if you count the human way, Same as above using position)
Example 5:
Remove-IseMenu Edit -disp SQLPSX
Remove the Edit menu from tab with displayname SQLPSX
Example 6:
Remove-IseMenu Edit SQLPSX
Remove the Edit menu from tab with displayname SQLPSX (Same as above using position)

Remove-ISEMenuItem
This is a helper function to remove menus from ISE addon menu. Remove Menu specified by name from the current tab, or a tab specified by Displayname or index
Example 1:
Remove-IseMenu -Name Edit
Remove the Edit menu from the current tab
Example 2:
Remove-IseMenu Edit
Remove the Edit menu from the current tab (Same as above using position)
Example 3:
Remove-IseMenu Edit -tab 1
Remove the Edit menu from the 2nd tab (if you count the human way)
Example 4:
Remove-IseMenu Edit 1
Remove the Edit menu from the 2nd tab (if you count the human way, Same as above using position)
Example 5:
Remove-IseMenu Edit -disp SQLPSX
Remove the Edit menu from tab with displayname SQLPSX
Example 6:
Remove-IseMenu Edit SQLPSX
Remove the Edit menu from tab with displayname SQLPSX (Same as above using position)

Last edited Mar 28, 2010 at 11:48 AM by kanthrc, version 1

Comments

No comments yet.