Disable multiple features
Description
This example shows how you can use the WindowsOptionalFeatureSet
composite resource to ensure
multiple Windows optional features are disabled.
With Ensure set to Present
and the Name property set to the array of
MicrosoftWindowsPowerShellV2
and Internet-Explorer-Optional-amd64
, the resource disables those
Windows optional features if they're enabled.
With LogPath set to C:\LogPath\Log.txt
, the resource writes the logs for disabling the
features to that file instead of %WINDIR%\Logs\Dism\dism.log
.
With Invoke-DscResource
The Invoke-DscResource
cmdlet doesn't support invoking composite resources. Instead, use the
WindowsOptionalFeature resource.
With a Configuration
This snippet shows how you can define a Configuration
with a WindowsOptionalFeatureSet
resource
block to ensure that the MicrosoftWindowsPowerShellV2
and Internet-Explorer-Optional-amd64
Windows optional features are disabled.
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 Disable {
Import-DscResource -ModuleName 'PSDscResources'
Node Localhost {
WindowsOptionalFeatureSet ExampleWindowsOptionalFeatureSet {
Name = @(
'TelnetClient'
'LegacyComponents'
)
Ensure = 'Absent'
RemoveFilesOnDisable = $true
}
}
}
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