Install multiple Windows features
Description
This example shows how you can use the WindowsFeatureSet
composite resource to ensure multiple
Windows features are installed with their subfeatures.
With Ensure set to Present
, IncludeAllSubFeature set to $true
, and Name set to the
array of Telnet-Client
and RSAT-File-Services
, the resource installs the Telnet-Client
and
RSAT-File-Services
Windows features and their subfeatures if they're not already installed.
With LogPath set to C:\LogPath\Log.log
, if the resource needs to install Telnet-Client
or
RSAT-File-Services
, the resource writes the installation logs to C:\LogPath\Log.log
.
With Invoke-DscResource
The Invoke-DscResource
cmdlet doesn't support invoking composite resources. Instead, use the
WindowsFeature resource.
With a Configuration
This snippet shows how you can define a Configuration
with a WindowsFeatureSet
resource block to
ensure that the Telnet-Client
and RSAT-File-Services
Windows features are installed with their
subfeatures.
Important
There's a limitation in machine configuration that prevents a DSC Resource from using any PowerShell cmdlets not included in PowerShell itself or in a module on the PowerShell Gallery. This example is provided for demonstrative purposes, but because the DSC Resource uses cmdlets from the DISM module, which ships as one of the Windows modules, it won't work in machine configuration.
Configuration Install {
Import-DscResource -ModuleName 'PSDscResources'
Node localhost {
WindowsFeatureSet ExampleWindowsFeatureSet {
Name = @(
'Telnet-Client'
'RSAT-File-Services'
)
Ensure = 'Present'
IncludeAllSubFeature = $true
LogPath = 'C:\LogPath\Log.log'
}
}
}
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for