PS - Features on Demand, Remove Unused Payload

You can use the following Power Shell command to remove the payload of any Windows features that are not installed on the system:

Get-WindowsFeature | Where-Object -FilterScript { $_.Installed -Eq $FALSE } | Uninstall-WindowsFeature -Remove

Windows 10

The features on demand offering provides additional options which can be pre-configure or remove existing options from within Windows 10 installation software prior to deployment. Organizations can also install features from local media or remove features on designated machines after the initial installation is completed. Reducing the size of the Windows 10 installation file has it merits as it reduces the footprint to which an attacker can attempt to gain access to. The smaller installation file size also addresses the need to install Windows 10 on hardware with less storage capacity.  Case in point:

Step 1: Mounting and Viewing Attributes of an Offline Image File
  1. Download and install the Windows ADK for Windows 10
  2. Run command prompt with administrator privileges
  3. Type and run the following command: 
    Dism /Get-ImageInfo /ImageFile:C:\<Insert Installed ADK directory here>\install.wim 
    NOTE: This provides confirmation of the .wim file to be modified
  4. Mount the offline Windows image by running the following command:
    Dism /Mount-Image /ImageFile:C:\<Insert Installed ADK directory here>\install.wim /Name:"Base Windows Image" /MountDir:C:\test\offline
  5. Enter the following command to list all of the features available: 
    Dism /Image:C:\test\offline /Get-Features
Step 2: Removing Windows 10 Features and Payload from the installation file
  1. Enter the following command in the command prompt to remove unwanted features as listed in Step 1.5 above:
    Dism /Image:C:\test\offline /Disable-Feature /FeatureName:<enter unwanted feature name here> /Remove
  2. Repeat the previous step to remove all unwanted features
  3. Once all unwanted features have been removed, enter the following command to commit the changes and unmount the image
    Dism /Unmount-Image /MountDir:C:\test\offline /Commit
Once completed, simply install the reduced Windows 10 Installation file on the desired device.

Reference -