C# 通过nuget解决PowerShell问题

C# 通过nuget解决PowerShell问题,c#,powershell,system.management,C#,Powershell,System.management,我正在开发一个使用System.Management.Automation库的程序,以便创建PowerShell的实例。比如: using (var instance = System.Management.Automation.PowerShell.Create()) { // do something } 为了避免强制用户安装PowerShell v3,我使用System.Management.Automation Nuget软件包版本6.3.9600.17400。在我的机器上进行

我正在开发一个使用System.Management.Automation库的程序,以便创建PowerShell的实例。比如:

using (var instance = System.Management.Automation.PowerShell.Create())
{
    // do something
}
为了避免强制用户安装PowerShell v3,我使用System.Management.Automation Nuget软件包版本6.3.9600.17400。在我的机器上进行测试时,出现以下错误:

尝试加载系统Windows PowerShell管理单元时出错。请联系Microsoft客户支持服务。-->System.Management.Automation.PSArgumentException:无法访问Windows PowerShell PowerShellEngine注册表信息

我迷路了。现在,我正在尝试在我的机器上安装PowerShell v3,看看它是否工作。我真的认为有这个软件包就行了。有什么我能做的吗


提前感谢

好吧,我放弃了使用PowerShell v3,而改用v1

因此,我从以下位置引用了System.Management.Automation.dll: C:\Windows\assembly\GAC\U MSIL\System.Management.Automation

到目前为止,我已经能够使用所需的管理单元了

可能想用您正在使用的C#或wahtever语言来标记它。