Disk Cleanup WinSxS folder in Windows Server 2012 (R2) using DISM

Here is how to clean up the WinSxs folder on Windows Server 2012 R2, to reclaim disk space.
This will delete superseded updates and unused system files to free up extra disk space.
It uses dism.exe‘s disk cleanup options.

Often the Windows component store folder(C:\Windows\WinSxS) will take up a lot of space on your servers. This folder contains all the files that are required for a Windows installation as well as any updates to those files are also held within the component store as the updates are installed

Here's how to use the DISM tool to safely free up space:

The basic command we use it: Dism.exe /online /Cleanup-Image. This has the following extra options:

/AnalyzeComponentStore
/StartComponentCleanup
/ResetBase with /StartComponentCleanup
/SPSuperseded

Open a PowerShell as Administrator, then:

Basically run the following to Analyse the space you can save:
dism.exe /online /Cleanup-Image /AnalyzeComponentStore (only works on 2012 R2 and later)

And you can run this to free up the space:
dism.exe /online /Cleanup-Image /StartComponentCleanup

In other versions of windows try these without risk (they just own't run if not available in that version). Run as admin cmd:
Method 1: DISM.exe /online /Cleanup-Image /spsuperseded
Method 2: VSP1CLN.EXE