3

Short of running dism /online /disable-feature /remove /featurename:featurename on every feature I'd like to prune, is there a way of removing the payload on disk for all disabled features?

Ben Voigt
  • 473
  • 6
  • 20
Martytoof
  • 135
  • 1
  • 6

1 Answers1

9

Powershell 3.0 in Windows 8 provides a new cmdlet named Get-WindowsOptionalFeature which can be used to query features and their current state. With a little filtering you can pass this along the chain and execute dism for each feature.

Get-WindowsOptionalFeature -Online | where { $_.State -match "Disabled" } | `
    foreach { `
        $_ = $_.FeatureName; `
        DISM /Online /Disable-Feature /FeatureName:$_ /Remove `
    }

Additional Links

jveazey
  • 206
  • 2
  • 6
  • I find that matching `Disabled$` is better because then it only processes features that aren't already in the "Disabled with Payload Removed" state. – Ben Voigt Sep 16 '16 at 15:42
  • PowerShell Remove-WindowsFeature -Remove can also do this against servers or server offline images. – Matthew Wetmore Dec 17 '16 at 06:50