我正在尝试使用本教程在我的 PowerShell ISE 中添加一个菜单项。
Function My-Custom-Function {
Write-Host “Running my very own function!”
}
$psISE.CustomMenu.Submenus.Add(“Run Custom Function”, {My-Custom-Function}, “Shift+Ctrl+f”)
但由于某种原因,我收到此错误:
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
我运行 Windows 7 Enterprise 并以管理员身份运行 PowerShell ISE...
对这个问题有什么想法吗?