In Windows 10, you can "Turn windows features on and off" in the control panel; you see a screen as such:
Let's say I want to select IIS 6 WMI Compatibility by using the Enable-WindowsOptionalFeature
command in powershell.
If I run :
Get-WindowsOptionalFeature "IIS 6 WMI Compatibility"
I get this error:
Get-WindowsOptionalFeature : A positional parameter cannot be found that accepts argument 'IIS 6 WMI Compatibility'.
At line:1 char:1
+ Get-WindowsOptionalFeature "IIS 6 WMI Compatibility"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-WindowsOptionalFeature], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand
Question
How do I map the names of these features to the PowerShell command?
End Goal
The end goal is to automate setting up a new developer and his machine.
Good you found a answer that works for you, but...
Yet, you don't need a function to use wildcards. Just do this...
Get-WmiObject -Class $Win32_OperatingSystem
SystemDirectory : C:\WINDOWS\system32
Organization :
BuildNumber : 17134
RegisteredUser :
SerialNumber : 00330-50027-66869-AAOEM
Version : 10.0.17134
$PSVersionTable
Name Value
---- -----
PSVersion 5.1.17134.165
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0, 5.0, 5.1.17134.165}
BuildVersion 10.0.17134.165
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
# List features all
(Get-WindowsOptionalFeature -Online -FeatureName '*') | Format-Table -Autosize
(Get-WindowsOptionalFeature -Online -FeatureName '*').Count
144
# List features for IIS
(Get-WindowsOptionalFeature -Online -FeatureName '*IIS*').Count
54
# List features for wmi
(Get-WindowsOptionalFeature -Online -FeatureName '*wmi*').Count
2
# List features for IIS or wmi
(Get-WindowsOptionalFeature -Online -FeatureName '*iis*|*wmi*').Count
55
# List features for IIS or wmi or hyperv
(Get-WindowsOptionalFeature -Online -FeatureName '*iis*|*wmi*|*hyper*').Count
63