Detecting and removing Windows 10/11 optional features via SCCM can be a bit of pain via inventory – as the class is not inventoried by default.
One alternative is using a compliance baseline – which provides a quicker turn-around for any remediation you may want to do and wont bloat your database with additional inventory.
Im going to use an example of the Windows 10 XPS printer.
- Create a configuration item
- Give the item a name, such as “CI – Detect XPS Printer”
- Select your platforms – most likely Windows 10 and 11
- Under Settings
- Give the Setting a name: “Settings – XPS Printer Disabled”
- Setting Type: Script
- Data Type: String
- Script: (Get-WindowsOptionalFeature -FeatureName Printing-XPSServices-Features -Online).State
- Remediation script : Disable-WindowsOptionalFeature -FeatureName Printing-XPSServices-Features -Online
- Compliance rules
- Name: Compliance – XPS Disabled
- Selected setting: The setting we made in the step above
- Value: Disabled
- Run the remediation script when this setting is noncompliant: Enabled
Then create your baseline which contains this CI and deploy to your desired collection(s).
This can obviously be adapted to work with any optional feature – Use Get-WindowsOptionalFeature -Online to help find the exact name of the feature you are looking for.