description | ms.date | ms.topic | title |
---|---|---|---|
Use the PSDscResources WindowsOptionalFeatureSet composite resource to disable multiple features.
|
08/08/2022 |
reference |
Disable multiple features |
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
.
The Invoke-DscResource
cmdlet doesn't support invoking composite resources. Instead, use the
WindowsOptionalFeature resource.
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.
:::code source="Disable.Config.ps1":::