32-bit Powershell: use the ServerManager module?

I am working with a 32-bit application that can run powershell fragments. I need to load the ServerManager module, which I would normally do with:

 Import-Module ServerManager 

But I get this error:

The specified ServerManager module was not loaded, because no valid module file was found in any module directory.

I assume that this is because the ServerManager module does not exist in the 64-bit modules directory, so I tried the following:

 Import-Module "C:\Windows\sysnative\WindowsPowerShell\v1.0\Modules\ServerManager" 

But now I get the error:

  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

Any suggestions on how I can use the ServerManager module from a 32-bit command line? Or another suggestion on how I can install the "Desktop Experience" feature on a 2008 R2 server (without using a user interface)?

+4
source share
2 answers

Your only real choice is to create a 64-bit instance of powershell.exe to process the server manager commands. Since the parent process is 32 bits, you need to use the same %windir%\sysnative to run powershell.exe.

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

(wrapped for clarity)

+3
source

In addition to x0n answer..read this http://karlprosser.com/coder/2011/11/04/calling-powershell-64bit-from-32bit-and-visa-versa/

this explains why and when Sysnative (32 to 64 bits) and when you should use SysWow64 (64 to 32 bits).

+1
source

Source: https://habr.com/ru/post/1437260/


All Articles