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?

  • I was going to suggest a bit of PowerShell, but Get-WindowsFeature doesn't seem to work on Windows 8... – Michael Hampton Feb 25 '13 at 21:31
  • Get-WindowsFeature and Install/Remove-WindowsFeature only work against Server. – Matthew Wetmore Dec 17 '16 at 6:49

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

| improve this answer | |
  • 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 6:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.