我试图通过使用this tutorial在我的PowerShell ISE中添加一个菜单项。无法在PowerShell中创建函数
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企业版和我运行的PowerShell ISE作为管理员...
对这个问题有什么想法?
这个函数是有效的,但是我没有在我的顶栏中找到子菜单项... – Michiel 2012-08-09 07:41:24