32-битный PowerShell: используйте модуль ServerManager?
-
12-12-2019 - |
Вопрос
Я работаю с 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?Или другое предложение о том, как я могу установить функцию «Опыт на рабочем столе» на сервере 2008 R2 (без использования пользовательского интерфейса)?
Решение
Ваш единственный реальный выбор здесь состоит в том, чтобы выделить 64-битный экземпляр PowerShell.exe, чтобы обработать команды диспетчера серверов.Поскольку родительский процесс составляет 32 бит, вам придется использовать тот же трюк %windir%\sysnative
для запуска PowerShell.exe.
%windir%\sysnative\windowspowershell\v1.0\powershell.exe
-command '& { ipmo servermanager; add-windowsfeature foo }'
.
(завернутый для ясности)