Clean winsxs folder – Windows Server

About:

Features on demand

managing roles and features is features on demand. This was introduced in Server 2012 and Windows 8 and it involves the Windows installer copying the installation files from the disk or image to our hard drive for us. 

It creates this on demand availability by creating a folder in the Windows directory named Windows SxS, for side by side. And that is convenient because we can have those files around whenever we need to do an installation. But we have found the downside to having those files sitting on every server. We now recognize that we are using a few gigabytes of storage on every server in our network for files that are exactly the same in every location. 

Steps:

  • Use PS to list all available feature
  • Filter by ones are not installed
  • Remove them and their installation files from the winsxs folder

Code:

Get-windowsfeature | where-object -filterscript {$_.installed -eq $false} | uninstall-windowsfeature -remove