You can use DISM to enable or disable Windows roles and features and also customize Windows images. It is a very convenient feature that enables you to deploy computers with pre-installed roles and features, thus avoiding the inconvenience of installing roles and features and restarting a server after server deployment.
You have to identify which features are available in the mounted image and the exact name of the feature or a role you want to add, using either /Get-Features or Enable-WindowsOptionalFeature in DISM and PowerShell, respectively.
To identify which roles and features are available in the image mounted in c:\mount using dism.exe, use the following command:
DISM.exe/image:c:\mount /Get-Features
This produces the following output:
Alternatively, use the following PowerShell command:
Get-WindowsOptionalFeature -Path C:\mount
This produces exactly the same output, as shown in the following screenshot:
Some PowerShell command alternatives produce the same output as dism.exe commands and some PowerShell commands generate a more informative output. Both alternatives accomplish the same results; it is up to your personal preference as to which commands to use.
To enable a specific feature in the image, such as IP Address Management (IPAM), use the following dism.exe command:
Sometimes, you want to disable a feature you no longer need or support. To disable a feature in an image, use the Disable-Feature option in DISM or the Disable-WindowsOptionalFeature command in PowerShell, as shown in the following example:
When you are finished servicing an image, or you want to service a different image, you have to unmount the image. You have to specify whether you want to save or discard these changes using the /commit or /discard options.
To unmount an image that's mounted to the c:\mount folder and save your changes, use the following code:
DISM DISM.exe /unmount-wim /mountdir:c:\mount /commit or DISM.exe /unmount-Image /mountdir:c:\mount /commit