32位Powershell:是否使用ServerManager模块?

32位Powershell:是否使用ServerManager模块?,powershell,scripting,import-module,Powershell,Scripting,Import Module,我正在使用一个可以运行powershell代码段的32位应用程序。我需要加载ServerManager模块,我通常会使用该模块: Import-Module ServerManager 但我得到了这个错误: 未加载指定的模块“ServerManager”,因为在任何模块目录中都找不到有效的模块文件 我假设,这是因为64位模块目录中不存在ServerManager模块,因此我尝试了以下操作: Import-Module "C:\Windows\sysnative\WindowsPowerShel

我正在使用一个可以运行powershell代码段的32位应用程序。我需要加载
ServerManager
模块,我通常会使用该模块:

Import-Module ServerManager
但我得到了这个错误:

未加载指定的模块“ServerManager”,因为在任何模块目录中都找不到有效的模块文件

我假设,这是因为64位模块目录中不存在ServerManager模块,因此我尝试了以下操作:

Import-Module "C:\Windows\sysnative\WindowsPowerShell\v1.0\Modules\ServerManager"
但现在我得到了一个错误:

Import-Module : Cannot load Windows PowerShell snap-in C:\Windows\assembly\GAC_MSIL\Microsoft.Windows.ServerManager.PowerSh ell\6.1.0.0__31bf3856ad364e35\Microsoft.Windows.ServerManager.PowerShell.dll because of the following error: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information. Loader Exceptions: Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. Could not load file or assembly 'Microsoft.Windows.ServerManager, Version=6.1.0.0, Culture=neutral, PublicKeyToken=31bf3856 ad364e35' or one of its dependencies. The system cannot find the file specified. At line:1 char:14 导入模块:无法加载Windows PowerShell管理单元C:\Windows\assembly\GAC\MSIL\Microsoft.Windows.ServerManager.PowerSh 由于以下错误,ell\6.1.0.0\uu 31bf3856ad364e35\Microsoft.Windows.ServerManager.PowerShell.dll无法加载 一个或多个请求的类型。有关详细信息,请检索LoaderExceptions属性。 加载程序异常: 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 无法加载文件或程序集“Microsoft.Windows.ServerManager,版本=6.1.0.0,区域性=中性,PublicKeyToken=31bf3856” ad364e35'或其依赖项之一。系统找不到指定的文件。 第1行字符:14
关于如何从32位powershell中使用ServerManager模块,有什么建议吗?或者关于如何在Server 2008 R2上安装“桌面体验”功能(不使用UI)的另一个建议?

这里您唯一真正的选择是生成powershell.exe的64位实例来处理您的服务器管理器命令。因为父进程是32位的,所以您必须使用相同的
%windir%\sysnative
技巧来启动powershell.exe

%windir%\sysnative\windowspowershell\v1.0\powershell.exe 
     -command '& { ipmo servermanager; add-windowsfeature foo }'
(为清晰起见,包装好)