Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将Powershell管理单元注册到特定版本的Powershell_Powershell_Pssnapin - Fatal编程技术网

将Powershell管理单元注册到特定版本的Powershell

将Powershell管理单元注册到特定版本的Powershell,powershell,pssnapin,Powershell,Pssnapin,我正在尝试通过托管代码运行Exchange命令行管理程序脚本。 我们的PowerShell版本是版本4。 我正在尝试使用runspaceConfiguration.AddPSSnapin()方法添加exchange管理单元Microsoft.exchange.Management.Powershell.E2010,但此行失败,给出: 尚未为Powershell版本4注册任何管理单元 快速Get-PSSnapIn-registered显示管理单元已安装,但已注册到PS版本1 在regEdit中,我

我正在尝试通过托管代码运行Exchange命令行管理程序脚本。 我们的PowerShell版本是版本4。 我正在尝试使用
runspaceConfiguration.AddPSSnapin()
方法添加exchange管理单元
Microsoft.exchange.Management.Powershell.E2010
,但此行失败,给出:

尚未为Powershell版本4注册任何管理单元

快速
Get-PSSnapIn-registered
显示管理单元已安装,但已注册到PS版本1

regEdit中,我找到了PowerShell v1管理单元的注册表项,使用导出功能编写了该项的脚本,将目标版本更改为4,并运行导出命令,该命令按预期在PowerShell下创建了新项“4”,并复制了管理单元的详细信息。但是,我仍然得到“没有为Powershell版本4注册任何管理单元”,即使注册表中有该项

我是否还应该做些什么来将管理单元注册到PowerShell版本4


谢谢您的时间。

您是对的,这是一个32/64位的构建问题。在我将VS中的目标构建设置为x64并重新部署后,所有这些都神奇地工作正常。
在本例中,有关Powershell版本的错误消息是一个大麻烦

它可能是一个模块,而不是管理单元。如果您使用InitialSessionState而不是RunspaceConfiguration,则可以使用iss.ImportModule,但我认为api在RunspaceConfiguration上不可用,因此您需要一个显式的导入模块命令,以便在运行空间打开后运行。