Table of contents
Collapse the table of content
Expand the table of content

DSC WindowsFeature Resource

Eric Slesar|Last Updated: 6/12/2017
2 Contributors

Applies To: Windows PowerShell 4.0, Windows PowerShell 5.0

The WindowsFeature resource in Windows PowerShell Desired State Configuration (DSC) provides a mechanism to ensure that roles and features are added or removed on a target node.


WindowsFeature [string] #ResourceName
    Name = [string]
    [ Credential = [PSCredential] ]
    [ Ensure = [string] { Absent | Present }  ]
    [ IncludeAllSubFeature = [bool] ]
    [ LogPath = [string] ]
    [ DependsOn = [string[]] ]
    [ Source = [string] ]


NameIndicates the name of the role or feature that you want to ensure is added or removed. This is the same as the Name property from the Get-WindowsFeature cmdlet, and not the display name of the role or feature.
CredentialIndicates the credentials to use to add or remove the role or feature.
EnsureIndicates if the role or feature is added. To ensure that the role or feature is added, set this property to "Present" To ensure that the role or feature is removed, set the property to "Absent".
IncludeAllSubFeatureSet this property to $true to ensure the state of all required subfeatures with the state of the feature you specify with the Name property.
LogPathIndicates the path to a log file where you want the resource provider to log the operation.
DependsOnIndicates that the configuration of another resource must run before this resource is configured. For example, if the ID of the resource configuration script block that you want to run first is ResourceName and its type is ResourceType, the syntax for using this property is DependsOn = "[ResourceType]ResourceName".
SourceIndicates the location of the source file to use for installation, if necessary.


WindowsFeature RoleExample
    Ensure = "Present" 
    # Alternatively, to ensure the role is uninstalled, set Ensure to "Absent"
    Name = "Web-Server" # Use the Name property from Get-WindowsFeature  
© 2017 Microsoft