Get-WindowsOptionalFeature无法正常工作

时间:2016-12-10 18:25:00

标签: powershell windows-10

我正在使用IIS和Windows PowerShell,基于此this Microsoft TechNet link我应该能够使用PowerShell命令查看操作系统的所有可选功能:

PS C:\> Get-WindowsOptionalFeature –Online

当我尝试使用此命令时,收到以下错误消息:

get-windowsoptionalfeature : An attempt was made to load a program with an incorrect format.
At line:1 char:1
+ get-windowsoptionalfeature -Online
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : NotSpecified: (:) [Get-WindowsOptionalFeature], COMException
+ FullyQualifiedErrorId : Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand

我一直在阅读,大多数问题似乎是基于64位和32位操作系统之间的问题,我已经尝试在我的标准PowerShell和PowerShell(x86)中运行它,两者都有相同的错误。关于为什么会发生这种情况的任何想法?

1 个答案:

答案 0 :(得分:4)

  1. Get-WindowsOptionalFeature cmdlet需要PowerShell 3.0。
  2. 此cmdlet必须以提升的权限运行。在按住CTRL键的同时右键单击Windows PowerShell 3.0控制台,然后从操作菜单中选择“以管理员身份运行”(按:https://blogs.technet.microsoft.com/heyscriptingguy/2012/08/24/use-powershell-3-0-to-find-enabled-windows-8-features/)。
  3. 必须安装RSAT才能使用它。我认为它与32位和64位没有任何关系。