Roles, features and the WinSxS folder in Windows Server 2012

Back in time when I had to install additional Windows Components on a 2003 Server the Windows Comopnents Wizard asked me to insert the install disk or point to a folder which contains the install files. In Windows Server 2008 this was changed and all files were copied to the C:\Windows\WinSxS folder so when I decided to install a feature or a role all files were already on the machine. Unfortunately these files cannot be removed but in Windows Server 2012 you have this option to save space, have smaller server footprint, and even satisfy your security officer: this is called features on demand.

Remove install files

On a freshly installed server the WinSxS folder looks like this:

WinSxS folder size
WinSxS folder size

Use Get-WindowsFeature command from a Powershell console to retrieve the current status of roles, role services and features on the server.

Windows features on Server 2012
Windows features on Server 2012

As you can see in the Install State column, an item can be in the following state:

  • Installed: the role or features is installed, the supporting files are on the server and it actively uses them
  • Available: the role or feature is NOT installed, but the supporting files are on the server ready, in case you want to install/enable that role or feature
  • Removed: the role or feature is NOT installed and the supporting files are removed from the server (you cannot see this on the screenshot above, but believe me Powershell-V2 is in a Removed state by default)

If you install a feature or role from the GUI their status will be Installed rather than Available and if you unistall them they will be in an Available state, not quite surprising. To do the same from Powershell, use the Install-WindowsFeature and the Uninstall-WindowsFeature commands with the appropriate parameters, respectively.

But to change the status of an item to Removed you have to use Uninstall-WindowsFeature with a specific switch parameter, called Remove.

Remove parameter of Uninstall-WindowsFeature
Remove parameter of Uninstall-WindowsFeature

Example: to remove Active Directory Domain Services supporting files use the following Powershell command: Uninstall-WindowsFeature AD-Domain-Services -Remove

Remove role or feature supporting files
Remove role or feature supporting files

To remove all unused role and feature supporting files use the following one-liner:

Get-WindowsFeature | Where-Object {$_.InstallState -Eq “Available”} | Uninstall-WindowsFeature -Remove

Removing not installed roles and features
Removing not installed roles and features

Take a look at WinSxS folder size after removing all unused roles and features:

WinSxS folder size
WinSxS folder size

Approximately saved 1,7 GB space.

One more thing about Uninstall-WindowsFeature, be careful with powershell help! I have just noticed the following:

Misleading example
Misleading example

The third example removes any roles or features that are currently INSTALLED on the target server contrary to the message!

Installing removed roles and features

Later you might want to install a role but the files are removed, so have to pay extra attention specifying source folder or image for files otherwise you might end up downloading all of them from the Internet through Windows Update.

Using the GUI

On the Confirmation page of the Add Roles and Features Wizard a message warns you that some source files are missing (the removed files from the WinSxS folder) and you have an additional option at the bottom of the page to be able to specify the source for these files.

Sepcify an alternate source path
Specify an alternate source path

If you have your DVD (image) ready specify the /sources/install.wim file location and an image number in the following format:

Alternate source path
Alternate source path

Other options are a network path to a WIM file or a network path to a WinSxS folder.

The last number is the index of an image in a WIM file. To retrieve this use DISM.EXE:

dism.exe /get-imageinfo /imagefile:d:\sources\install.wim

Images in a WIM file
Images in a WIM file

Using Powershell

Not surprisingly you have to use Install-WindowsFeature and use the -Source parameter to accomplish the same with powershell:

Install-WindowsFeature AD-Domain-Services -Source WIM:d:\sources\install.wim:4

Install feature and specifying source
Install feature and specifying source

Conclusion

Save space and have smaller server footprint by removing roles and features supporting files: Uninstall-WindowsFeature <featurename> -remove

During installation specify a source path to copy the files from: Install-WindowsFeature <featurename> -Source <source path>

Use dism to retrieve information about images in a WIM file.

I have only one question: Is it possible to control this during installation and do not copy these files at all?

Advertisements

2 thoughts on “Roles, features and the WinSxS folder in Windows Server 2012”

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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