Paul Gregory | 12 April 2013
With Windows Vista and Windows 7 we had tools that enabled the removal of old source files once a service pack has been applied. With Windows Server 2012 Microsoft has provided a way to remove all the source files for the unneeded roles and features
Windows Server 2012 is the same as most recent
versions of Windows and that most of the source files, (the
exceptions are PS v2 and previous versions of .net), are stored on
the hard disk in the WINSxS folder inside the Windows directory.
These files take up about 1.7GB. In addition when the system is
updated these files get updated two so you end up with multiple
versions of these files on the disk. Therefore the ability to
remove unneeded source files not only helps with this but would
also reduce the OS footprint size which can help when building
images, VM templates and increasing density of VM with reduce
storage consumption on LUNs.
The basic command is the Uninstall-WindowsFeature PowerShell command with the - Remove option to remove the source files. To be able to remove all the source files for uninstalled features the command would be:
Get-WindowsFeature | Where-Object installedstate -eq "available" | Remove-WindowsFeature -Remove
The question now is what if a feature needs to be installed that has had its source files removed. When installing the new feature (either through Server Manager or PowerShell) the source location can be specified. The great thing about this feature is you can either download the content from the Windows Update site or point it directly at the WIM file using the format below:
This command specifies the source object is a
WIM file with the WIM: option, next the location of the WIM file,
and lastly the specific image in the WIM file.
Please watch this video to see this feature in action, or attend a training course on Windows Server 2012 @QATraining