| description | Examples showing how to install and remove Windows features on demand (capabilities) using the Microsoft.Windows/FeatureOnDemandList resource. |
|---|---|
| ms.date | 04/21/2026 |
| ms.topic | reference |
| title | Install and remove features on demand |
This example shows how you can use the Microsoft.Windows/FeatureOnDemandList resource to install
and remove Windows features on demand (capabilities). The examples use
OpenSSH.Client~~~~0.0.1.0 as a representative capability identity.
Important
All operations with Microsoft.Windows/FeatureOnDemandList require an elevated (administrator)
session. Run your terminal as administrator before executing these commands.
Note
Installing a capability may require internet access or an appropriately configured Windows Update or WSUS source. Installing large capabilities may take several minutes to complete.
To install a capability, set its state to Installed and use the dsc resource set
command.
$instance = @{
capabilities = @(
@{
identity = 'OpenSSH.Client~~~~0.0.1.0'
state = 'Installed'
}
)
} | ConvertTo-Json -Depth 3
dsc resource set --resource Microsoft.Windows/FeatureOnDemandList --input $instanceWhen the resource installs the capability, DSC returns the updated state:
beforeState:
capabilities:
- identity: OpenSSH.Client~~~~0.0.1.0
state: NotPresent
displayName: OpenSSH Client
description: Open SSH-based secure shell (SSH) client...
downloadSize: 4026000
installSize: 4894720
afterState:
capabilities:
- identity: OpenSSH.Client~~~~0.0.1.0
state: Installed
displayName: OpenSSH Client
description: Open SSH-based secure shell (SSH) client...
downloadSize: 0
installSize: 4894720
changedProperties:
- capabilitiesIf a system restart is required to complete the installation, the response includes a
_restartRequired property at the top level:
afterState:
_restartRequired:
- system: MYCOMPUTER
capabilities:
- identity: SomeCapability~~~~0.0.1.0
state: InstallPending
...
changedProperties:
- capabilitiesTo remove a capability, set its state to NotPresent and use the dsc resource set command.
$instance = @{
capabilities = @(
@{
identity = 'OpenSSH.Client~~~~0.0.1.0'
state = 'NotPresent'
}
)
} | ConvertTo-Json -Depth 3
dsc resource set --resource Microsoft.Windows/FeatureOnDemandList --input $instancebeforeState:
capabilities:
- identity: OpenSSH.Client~~~~0.0.1.0
state: Installed
displayName: OpenSSH Client
description: Open SSH-based secure shell (SSH) client...
downloadSize: 0
installSize: 4894720
afterState:
capabilities:
- identity: OpenSSH.Client~~~~0.0.1.0
state: NotPresent
displayName: OpenSSH Client
description: Open SSH-based secure shell (SSH) client...
downloadSize: 4026000
installSize: 4894720
changedProperties:
- capabilitiesTo allow DISM to install capabilities that are not present on the machine in an offline
environment, add the offline source path to the sourcePaths property.
$instance = @{
sourcePaths = @('z:\sources\SxS')
capabilities = @(
@{
identity = 'NetFX3~~~~'
state = 'Installed'
}
)
} | ConvertTo-Json -Depth 3
dsc resource set --resource Microsoft.Windows/FeatureOnDemandList --input $instanceWhen the resource installs the capability, DSC returns the updated state:
beforeState:
sourcePaths:
- z:\sources\SxS
capabilities:
- identity: NetFX3~~~~
state: NotPresent
displayName: ''
description: ''
downloadSize: 0
installSize: 487706170
afterState:
sourcePaths:
- z:\sources\SxS
capabilities:
- identity: NetFX3~~~~
state: Installed
displayName: ''
description: ''
downloadSize: 0
installSize: 487706170
changedProperties:
- capabilitiesYou can install or remove multiple capabilities in a single Set call by specifying multiple
entries in the capabilities array. The resource processes each entry independently.
$instance = @{
capabilities = @(
@{
identity = 'OpenSSH.Client~~~~0.0.1.0'
state = 'Installed'
}
@{
identity = 'OpenSSH.Server~~~~0.0.1.0'
state = 'NotPresent'
}
)
} | ConvertTo-Json -Depth 3
dsc resource set --resource Microsoft.Windows/FeatureOnDemandList --input $instanceYou can also use the resource in a DSC configuration document to declaratively manage capabilities across a system.
# features-on-demand.config.dsc.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Manage OpenSSH capabilities
type: Microsoft.Windows/FeatureOnDemandList
properties:
capabilities:
- identity: OpenSSH.Client~~~~0.0.1.0
state: Installed
- identity: OpenSSH.Server~~~~0.0.1.0
state: NotPresentApply the configuration with the dsc config set command:
dsc config set --file ./features-on-demand.config.dsc.yaml