【发布时间】:2016-06-28 22:42:40
【问题描述】:
Collection<PSObject> PSOutput;
using (PowerShell PowerShellInstance = PowerShell.Create())
{
PowerShellInstance.AddScript("Show-Command -name Get-Content -PassThru");
PSOutput = PowerShellInstance.Invoke();
}
这不返回任何输出,但 PowerShellInstance 上存在错误,其错误流具有空引用异常
在 Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper.GetHostWindow(PSCmdlet cmdlet) 在 Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper.CallShowDialog(PSCmdlet cmdlet) 在 Microsoft.PowerShell.Commands.ShowCommandInternal.ShowCommandHelper.ShowCommandWindow(PSCmdlet cmdlet、对象 commandViewModelObj、Double windowWidth、Double windowHeight, Boolean passThrough)
【问题讨论】:
-
从反编译代码来看,这是一个错误,要求使用的PowerShell主机的
PSHost.PrivateData返回不是null对象。
标签: c# powershell