32-битная Powershell: использовать модуль ServerManager?

Я работаю с 32-битным приложением, которое может запускать фрагменты PowerShell. Мне нужно загрузить модуль ServerManager, что я обычно и делаю:

Import-Module ServerManager

Но я получаю эту ошибку:

Указанный модуль «ServerManager» не был загружен, так как ни в одном из каталогов модуля не найден допустимый файл модуля.

Я предполагаю, что это связано с тем, что модуль ServerManager не существует в каталоге 64-битных модулей, поэтому я пробовал следующее:

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

Любые предложения о том, как я могу использовать модуль ServerManager из 32-битной PowerShell? Или другое предложение о том, как я могу установить функцию «Рабочий стол» на Server 2008 R2 (без использования пользовательского интерфейса)?


person Kyle    schedule 01.10.2012    source источник


Ответы (1)


Ваш единственный реальный выбор здесь — создать 64-битный экземпляр powershell.exe для обработки команд вашего диспетчера сервера. Поскольку родительский процесс является 32-разрядным, вам придется использовать тот же прием %windir%\sysnative для запуска powershell.exe.

%windir%\sysnative\windowspowershell\v1.0\powershell.exe 
     -command '& { ipmo servermanager; add-windowsfeature foo }'

(завернуто для ясности)

person x0n    schedule 02.10.2012