PowerShell Add-WindowsFeature unrecognized

Issue ended up being that the metadata for ServerManager was 3.0 on these servers, yet the developed exe for calling PowerShell commands was only version 2.0. When it tried to import the modules, schema errors about the metadata were returned, but the EXE didn't redirect them to stdout, hence no response.

Import-Module : The 'C:\Windows\system32\WindowsPowerShell\v1.0\Modules\Serveranager\ServerManager.psd1' module cannot be imported because its manifest contins one or more members that are not valid. The valid manifest members are ('ModuleToProcess', 'NestedModules', 'GUID', 'Author', 'CompanyName', 'Copyright', 'ModuleVersion', 'Description', 'PowerShellVersion', 'PowerShellHostName', 'PowerShellHostVersion', 'CLRVersion', 'DotNetFrameworkVersion', 'ProcessorArchitecture', 'RequiredModules', 'TypesToProcess', 'FormatsToProcess', 'ScriptsToProcess', 'PrivateData', 'RequiredAssemblies', 'ModuleList', 'FileList', 'FunctionsToExport', 'VariablesToExport', 'AliasesToExport', 'CmdletsToExport'). Remove the members that are not valid ('HelpInfoUri', 'RootModule'), then try to importthe module again.
    At line:1 char:14
    + Import-Module <<<<  ServerManager; Get-Module
        + CategoryInfo          : InvalidData: (C:\Windows\syst...verManager.psd1:String) [Import-Module], InvalidOperationException
        + FullyQualifiedErrorId : Modules_InvalidManifestMember,Microsoft.PowerShell.Commands.ImportModuleCommand

On Windows Server 2016, while installing ADFS as a workaround I copied the C:\Windows\system32\WindowsPowerShell\v1.0\Modules folders to C:\Users\vagrant\Documents\WindowsPowerShell\Modules and it worked!


This is probably because the PowerShell script is being launched from a 32 bit instance of PowerShell. The ServerManager commands are only available from 64 bit version of PowerShell. See: Can't access ServerManager module via PowerShell

--Edit - To add to jbsmith's comments---

Extra things to try:

When you ran the Get-Command cmdlt:

gcm | ? { $_.ModuleName -eq 'ServerManager' }

It will return nothing because the ServerManager module has not been loaded.

Try running this instead. It will list all available modules to load:

Get-Module -ListAvailable | ? { $_.Name -eq 'ServerManager' }

The other thing to try is to use the "Force" option (Re-imports a module and its members, even if the module or its members have an access mode of read-only):

Import-Module ServerManager -Force;
Get-WindowsFeature;