I'm attempting to use PowerShell to install a Windows Feature (don't ask) as part of a project. In the PowerShell console I can run the command:
Get-WindowsOptionalFeature -Online -FeatureName "IIS-WebServerRole"
and it completes successfully. When I then try to run this from the PM> prompt in Visual Studio 2015 (running as administrator) it then gives me the following error:
get-windowsoptionalfeature : An attempt was made to load a program with an incorrect format.
At line:1 char:1
+ get-windowsoptionalfeature -online -featurename "IIS-WebServerRole"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Get-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand
Here is my current $PSVersionTable from wihtin Package Manager.
Name Value
---- -----
PSVersion 5.1.14393.206
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14393.206
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
I can successfully run get-help get-windowsoptionalfeature and it will show syntax for the command. I also ran the command in a try catch block to get the exception, here is what it returned:
System.Runtime.InteropServices.COMException (0x8007000B): An attempt was made to load a program with an incorrect format.
at System.Management.Automation.MshCommandRuntime.ThrowTerminatingError(ErrorRecord errorRecord)
What, if anything, can I do to fix not being able to use Get-WindowsOptionalFeature from the Package Manager console?