Create menu item in Powershell ISE

13/10/2012 05:28

 

#IItem is added to 'Add-ons' menu in Powershell ISE
#it is there only until you close an instance of powershell
 
function AddPSSnapin
{
    # check to ensure Microsoft.SharePoint.PowerShell is loaded
    $snapin=Get-PSSnapin | Where-Object {
       $_.Name -eq 'Microsoft.SharePoint.Powershell'}
       if ($snapin -eq $null) {
       Write-Host "Loading SharePoint Powershell Snapin"
       Add-PSSnapin "Microsoft.SharePoint.Powershell"
       }
}
 
$menuAdded = $psISE.CurrentPowerShellTab.AddOnsMenu.SubMenus.Add("_Add PS Snapin",{AddPSSnapin},"Alt+P")