Cleaning Up Windows SxS Folder in Preparation for Imaging

In preparation for releasing an operating system image to be used as a WM template I usually like to perform some “shrinking commands” to make sure the image has as small a foot-print as possible.

All the “shrinking commands” are all command line or PowerShell based because they must also be able to be performed on a Windows Server Core installation.

Remove all Uninstalled Feature Binaries

The first thing I usually do is remove any uninstalled feature binaries (as part of Windows Features on Demand). I’ve covered this in an earlier article here.

Remove Old Service Pack Backup Files

The following command removes any files that were backed up as part of installing a service pack. If you execute this command you won’t be able to uninstall any service packs.

DISM /online /cleanup-image /SPSuperseded
DISM /online /cleanup-image /SPSuperseded

DISM /online /cleanup-image /SPSuperseded

Remove Superceeded Components

This command removes any components in the Windows SxS folder that have been superceeded by newer versions.

Windows Server 2008/2008 R2/2012 and Windows 7/8:

DISM /online /cleanup-image /StartComponentCleanup

Windows Server 2012 R2 and Windows 8.1 (performs some additional optimization):

DISM /online /cleanup-image /StartComponentCleanup /ResetBase
DISM /online /cleanup-image /StartComponentCleanup /ResetBase

DISM /online /cleanup-image /StartComponentCleanup /ResetBase

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s