Today I noticed that Get-WindowsOptionalFeature and Enable-WindowsOptionalFeature cmdlets in DISM module of PowerShell V3 are failing with below error.
Get-WindowsOptionalFeature : Parameter set cannot be resolved using the specified named parameters.
At line:1 char:1
+ Get-WindowsOptionalFeature
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Get-WindowsOptionalFeature], ParameterBindingException
+ FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.Dism.Commands.GetWindowsOptionalFeatureCommand
After little research I understood that, DISM module is designed to work with offline images by default. To use them against a online server, we should use-Onlineswitch.
I did that and able to install telnetclient feature without any issues using the below sequence of commands.
Get-WindowsOptionalFeature -Online -FeatureName TelnetClient Enable-WindowsOptionalFeature -Online -FeatureName TelnetClient Get-WindowsOptionalFeature -Online -FeatureName TelnetClient
The big question that is still left my mind is, “Do I need to do that for every cmdlet in DISM module I use?”. Fortunately, there is a way available to get rid this -Online parameter.
The workaround is to add the online option to default parameters (Source: ITfishihngpole.com).
$PSDefaultParameterValues = @{"*WindowsOptionalFeature:Online"=$true}
After this you can run Get-WindowsOptionalFeature or any other cmdlet in DISM module without -Online option.
[SourceCode]
PS C:\Users\Administrator> Get-WindowsOptionalFeature -FeatureName telnetClient
Feature Name : TelnetClient
Display Name : Telnet Client
Description : Allows you to connect to other computers remotely.
Restart Required : Possible
State : Disabled
Custom Properties :
ServerComponent\Description : Telnet Client uses the
Telnet protocol to connect to a remote Telnet server and run applications on that server.
ServerComponent\DisplayName : Telnet Client
ServerComponent\Id : 44
ServerComponent\Type : Feature
ServerComponent\UniqueName : Telnet-Client
ServerComponent\Version\Major : 6
ServerComponent\Version\Minor : 2
ServerComponent\Deploys\Update\Name : TelnetClient
PS C:\Users\Administrator>
[/SourceCode]
Hope this helps.