Remove unused role and feature payload files from WS 2012

Windows Server 2012 allows you to remove the installation files for roles and features that you don't use. Here's a one line Windows PowerShell command that will do it for you.

Once you’ve deployed a server, such as a DC or a File Server, chances are that you won’t need to add any additional roles and features to that server. The Features on Demand technology of Windows Server 2012 allows you to remove the installation files for roles and features that you don't use. You can free up around 2 GB on some servers by removing these files. You can also add the files back in future should it be necessary.

The following Windows PowerShell command will remove all roles and feature payload files on the server that are not currently installed. It does this by figuring out the list of roles and features that aren’t installed and piping them across to the uninstall-windowsfeature cmdlet with the Remove option. To get this to work, you’ll need to run it from an elevated Windows PowerShell prompt.

Get-WindowsFeature | Where-Object {$_.Installed –eq $False} | Uninstall-WindowsFeature -Remove

Please or Register to post comments.

What's Hyperbole, Embellishment, and Systems Administration Blog?

IT pro Orin Thomas provides true tales, snafus, news, and urban legends for Microsoft Windows system administrators.

Contributors

Orin Thomas

Orin Thomas is a contributing editor for Windows IT Pro and a Windows Security MVP. He has authored or coauthored more than a dozen books for Microsoft Press, and he writes the Hyperbole,...
Blog Archive

Sponsored Introduction Continue on to (or wait seconds) ×