Skip to content

Instantly share code, notes, and snippets.

@aplocher
Created August 22, 2015 12:03
Show Gist options
  • Save aplocher/7a559c3de6f480e4f6f4 to your computer and use it in GitHub Desktop.
Save aplocher/7a559c3de6f480e4f6f4 to your computer and use it in GitHub Desktop.
Small PowerShell script that looks at the currently installed Windows Features on the current system and generates a dism.exe/ cmd.exe command to be used to restore those features. Handy for when you're reinstalling Windows on a machine and want to backup / restore your IIS, Hyper-V, etc configuration.
$o=$nothing
Get-WindowsOptionalFeature -Online | where State -eq Enabled | %{$o += ("/FeatureName:"+$_.FeatureName+" ")}
Write-Host "dism.exe /Online /Enable-Feature $o/All"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment