1

Observe the following DSC configuration:

Configuration Example
{
     Import-DscResource –ModuleName PSDesiredStateConfiguration

     node localhost
     {
          WindowsFeature 'NetFramework45'
          {
               Name   = 'NET-Framework-45-Core'
               Ensure = 'Present'
          }
     }
}

It enables the .NET 4.5 on a Windows Server. But the WindowsFeature resource only works on server. Now, I would like to reach the same effect on a non server machine. What would be the right way to express it in PowerShell DSC?

2
  • Which version of Windows client? .Net 4.5 isn't configurable on Windows 10. Broadly, the WindowsFeature DSC resource relies on Install-WIndowsFeature which is only available on Server. For non-server (aka client), you'll need to use the WindowsOptionalFeature DSC resource that acts directly through DISM, documented at docs.microsoft.com/en-us/powershell/dsc/…. The names of the features for DISM are different than Install-WindowsFeature. You can list features with dism.exe /online get-features. Apr 15, 2018 at 20:01
  • Could you provide an answer (with example, if possible) so that I could credit you?
    – mark
    Apr 15, 2018 at 20:40

1 Answer 1

3

The WindowsFeature DSC resource is based on the Install-WindowsFeature cmdlet, and is only available on Server.

To enable features on Windows client (i.e. non-Server), you'll need to use the WindowsOptionalFeature resource, which works over DISM.

To enumerate a list of features on your particular version, you can use Get-WindowsOptionalFeature -Online or DISM from the command line: dism.exe /online /get-features.

You asked about NET-Framework-45-Core. This is not a separately installable/removable feature on Windows 10 client, for example.

To identify the DISM features for any particular Windows Server feature, you can look at the results of (Get-WindowsFeature <name>).AdditionalInfo.InstallName. For example, the DISM feature for NET-Framework-45-Core is NetFx4.

Note that while DISM.exe and WindowsOptionalFeature also work on Windows Server, it is not recommended as the relationships between features in Server is more complicated and those relationships are understood and managed by additional metadata exposed through the *-WindowsFeature cmdlets, as well as Server Manager and a WMI provider. Directly installing the discovered DISM features as described above will not necessarily install all needed or recommended additional components to make the feature work correctly.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .