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?
Asked
Active
Viewed 2,962 times
3
-
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 06:49
1 Answers
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