xPSDesiredStateConfiguration icon indicating copy to clipboard operation
xPSDesiredStateConfiguration copied to clipboard

Missing ALL parameter in cWindowsOptionalFeature

Open asmagin opened this issue 8 years ago • 9 comments

cWindowsOptionalFeature doesn't support parameter "ALL" that will install all parent features, which may result in errors during installation and require more detailed configurations. Would be great if this parameter would be added.

asmagin avatar May 10 '16 20:05 asmagin

This repository doesn't have any control over cWindowsOptionalFeature. Do you mean xWindowsOptionalFeature?

And I'm not sure what you mean by install all parent features. Do you mean install all dependencies?

kwirkykat avatar Jun 17 '16 01:06 kwirkykat

https://technet.microsoft.com/en-us/itpro/powershell/windows/dism/enable-windowsoptionalfeature#-all

There are some dependencies between features. e.g. if you run

Get-WindowsFeature | Where Name -match "Net-Frame"

You will see that features organized in a tree according to the dependencies.

You won't be able to install NET-FRAMEWORK-CORE, if you do not have NET-FRAMEWORK-FEATURES

asmagin avatar Apr 03 '17 13:04 asmagin

@asmagin Could you please provide a configuration that reproduces your problem, to see if there is a way to make a tests to see how this can be solved.

johlju avatar May 11 '18 14:05 johlju

I was quite a while ago, but I believe that Windows 2012 R2 clean installation should not have the latests framework installed. Try to install NET-FRAMEWORK-CORE feature there. It should fail.

asmagin avatar Jun 11 '18 14:06 asmagin

Started out uninstalled:

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[ ] .NET Framework 3.5 Features                         NET-Framework-Features         Available
    [ ] .NET Framework 3.5 (includes .NET 2.0 and 3.0)  NET-Framework-Core             Available

Running this configuration:

            xWindowsFeature $resourceConfigName {
                Name = 'NET-Framework-Core'
                Ensure = 'Present'
            }

Resulted in:

Display Name                                            Name                       Install State
------------                                            ----                       -------------
[X] .NET Framework 3.5 Features                         NET-Framework-Features         Installed
    [X] .NET Framework 3.5 (includes .NET 2.0 and 3.0)  NET-Framework-Core             Installed

Updated to correct resource name.

johlju avatar Jun 12 '18 10:06 johlju

We could also have added both to make sure both are always in desired state.

xWindowsFeature $resourceConfigName {
    Name = 'NET-Framework-Features'
    Ensure = 'Present'
}

xWindowsFeature $resourceConfigName {
    Name = 'NET-Framework-Core'
    Ensure = 'Present'
}

Closing this issue at this time.

johlju avatar Jun 12 '18 10:06 johlju

@johlju As I told you the issues was reported 2 years ago and some details are blurry, but I looked through the code of module and link that I posted above.

xWindowsOptionalFeature uses dism inside. I believe it is used not on server but on 8, 8.1 and maybe on 10. According to the documentation of dism you can pass -All flag to ensure that dependencies will be installed. And the module is not passing this parameter.

https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/33d8027aae3fa7aeda22a7f4d1643f027aaa5c3f/DSCResources/MSFT_xWindowsOptionalFeature/MSFT_xWindowsOptionalFeature.psm1#L138-L143

PS: just noticed that you are testing different resource in your example.

asmagin avatar Jun 12 '18 10:06 asmagin

Yes I saw that I tested the wrong resource too :smile: As per your previous comment I reopen this and label it as an enhancement and help wanted.

johlju avatar Jun 12 '18 10:06 johlju

You can add All switch similar to [Boolean] $IncludeAllSubFeature = $false, in function you actually tested: https://github.com/PowerShell/xPSDesiredStateConfiguration/blob/33d8027aae3fa7aeda22a7f4d1643f027aaa5c3f/DSCResources/MSFT_xWindowsFeature/MSFT_xWindowsFeature.psm1#L194-L198

asmagin avatar Jun 12 '18 10:06 asmagin