Features on Demand in Windows Server 2012

Before you start

Objectives: Learn how to uninstall features and how to completely remove feature payload from the disk in Windows Server 2012.

Prerequisites: no prerequisites.

Key terms: binaries, features, removal, payload, uninstall, Server 2012.

 What is Features on Demand

In previous versions of Windows Server, when we installed the system, all the binaries from all the features were copied to the disk, even if the feature was not enabled. For example, if we didn’t use DNS features in Windows Server 2008, the binaries for DNS were still on the disk and consumed space.

With features on demand, when we don’t use certain feature, the binaries for that feature won’t be on the disk. So, we can remove unused features from disk. We can always get back those binaries if we change our mind. We can get those binaries (source files) from Windows Update or from a source WIM file (installation media).

To remove features from the disk we use PowerShell. We can also use this to remove features from Virtual Hard Disks (VHDs). As you know, VHDs are actually files on our hard disk which can be used by Virtual Machines (VMs). VMs will see VHDs as regular disks on the system. So, we can modify VHDs even without VM being turned on.

How to Remove Features

To remove features from the local machine we can simply run PowerShell as an administrator and type in the command:

Uninstall-WindowsFeature -name [feature-name] –Remove

With the -name flag we specify which feature we want to remove. To get the names of all the features you can use the Get-WindowsFeature command. This will show you the current state of the system and exact names of the features. With the -Remove flag we specify that we want to remove binaries (payload) from the disk. If we don’t use -Remove, the feature will be uninstalled, but the payload will stay on the disk. For example, if we wanted to remove Hyper-V feature, we would enter the command:Uninstall-WindowsFeature -name Hyper-V -Remove.

We can also remove features on remote computers by specifying the computer with the -computer [computer-name] flag. As we mentioned earlier, we can also do this on a VHD by specifying the -vhd [path-to-vhd] flag. Note that the extension of VHD file is .vhd or newer .vhdx.