所以这里是powershell:
$app = Get-WmiObject -Class SMS_UserApplicationRequest -Namespace root/SMS/site_sitename -
ComputerName computername | Select-Object User, Application, RequestGUID
$app
它工作正常,返回信息没有问题。
在 C# 中运行:
Runspace runspace = RunspaceFactory.CreateRunspace();
runspace.Open();
PowerShell powerShell = PowerShell.Create();
powerShell.Runspace = runspace;
powerShell.AddScript(script);
Collection<PSObject> results = powerShell.Invoke();
foreach (PSObject result in results)
{
MessageBox.Show(result.ToString());
}
runspace.Close();
这显示了baseObject,即UserApplicationRequest,但是如何访问请求中的数据呢?(那是 Select-Object User, Application, RequestGUID)