32ビットPowerShell:ServerManagerモジュールを使用しますか?
-
12-12-2019 - |
質問
PowerShellスニペットを実行できる32ビットアプリケーションで作業しています。ServerManager
モジュールをロードする必要があります。これは通常次のものとします。
Import-Module ServerManager
.
しかし私はこのエラーを得る:
指定されたモジュール 'serverManager'は、任意のモジュールディレクトリに有効なモジュールファイルが見つからなかったためロードされませんでした。
iを想定していると仮定すると、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.
32ビットPowerShell内からServerManagerモジュールを使用できる方法についての提案はありますか?またはサーバー2008 R2に「デスクトップエクスペリエンス」機能をインストールする方法についての別の提案(UIを使用せずに)?
解決
あなたの唯一の実際の選択は、あなたのサーバーマネージャーコマンドを処理するためにPowerShell.exeの64ビットインスタンスを生成することです。親プロセスは32ビットであるため、PowerShell.exeを起動するために同じ%windir%\sysnative
トリックを使用する必要があります。
%windir%\sysnative\windowspowershell\v1.0\powershell.exe
-command '& { ipmo servermanager; add-windowsfeature foo }'
.
(明確さのために包まれた)
所属していません StackOverflow