[英]System.Management.Automation.PSArgumentException
I have a problem running a PowerShell Script from my C# Code. 我从我的C#代码运行PowerShell脚本时遇到问题。 The script contains functions from the PowerShell Snapin VMWare.View.Broker
. 该脚本包含PowerShell Snapin VMWare.View.Broker
中的函数。 I do that in the following way: 我通过以下方式做到这一点:
PSSnapInException psEx;
RunspaceConfiguration runConfig = RunspaceConfiguration.Create();
runConfig.AddPSSnapIn("VMWare.View.Broker", out psEx);
using (Runspace runspace = RunspaceFactory.CreateRunspace(runConfig))
{
runspace.Open();
using (Pipeline pipeline = runspace.CreatePipeline())
{
string scriptContent = ReadScriptFromFile(scriptPath);
if (!String.IsNullOrEmpty(scriptContent))
{
pipeline.Commands.AddScript(scriptContent);
var results = pipeline.Invoke();
runspace.Close();
foreach (var result in results)
{
Console.WriteLine(result);
if(!String.IsNullOrEmpty(result.ToString()))
scriptResult += result+"_";
}
}
}
}
When I run my programm with the platform target x64 it works fine. 当我使用平台目标x64运行程序时,它可以正常工作。 But when I try to execute my programm with x86 I'm getting the following Exception (I need to run the programm with x86 due to other dependencies): 但是,当我尝试使用x86执行程序时,出现以下异常(由于其他依赖性,我需要使用x86运行程序):
System.Management.Automation.PSArgumentException: The Windows PowerShell snap-in
'VMWare.View.Broker' is not installed on this machine.
at System.Management.Automation.PSSnapInReader.ReadOne(RegistryKey mshSnapInRoot, String mshsnapinId)
The Vmware snapin is 64 bit and not 32 bits. Vmware管理单元是64位而不是32位。 The answer is in the error message. 答案在错误消息中。 You can try to find a 32 bits Vmware snapin and install it. 您可以尝试查找并安装32位Vmware管理单元。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.