I'm trying to add a menu-item in my PowerShell ISE by using this tutorial.
Function My-Custom-Function {
Write-Host “Running my very own function!”
}
$psISE.CustomMenu.Submenus.Add(“Run Custom Function”, {My-Custom-Function}, “Shift+Ctrl+f”)
But for some reason I get this error:
You cannot call a method on a null-valued expression.
At line:5 char:31
+ $psISE.CustomMenu.Submenus.Add <<<< (“Run Custom Function”, {My-Custom-Function}, “Shift+Ctrl+f”)
+ CategoryInfo : InvalidOperation: (Add:String) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
I run Windows 7 Enterprise and I run the PowerShell ISE as Administrator...
Any thoughts about this issue?