Brad Dickinson

How to use the DISM Tool to Manage Windows Features

The content below is taken from the original ( How to use the DISM Tool to Manage Windows Features), to continue reading please visit the site. Remember to respect the Author & Copyright.


The Deployment Image Servicing and Management (DISM) command-line tool and associated Powershell module are powerful tools to manipulate Windows image .wim files, virtual hard disks .vhd files, and control of Windows features and drivers.

Even more powerful is the ability to service offline images. In the past, there were many utilities that were used, but DISM is intended to replace several such as PEimg, Intlcfg, ImageX, and Package Manager.

Using DISM

To start with, open an administrative command prompt and simply type dism. Initial output is the version and options available, of which there are many.

Image #1 Expand

In this article, we are focused on how to use DISM to specifically add or remove Windows features. With that in mind, let’s explore what functionality exists to enable this.

DISM Feature Functionality

There are four main functions that are used with managing features. Below we will run through each one and explore exactly how they are used.

Get-Features

To understand what features are available, and the current state, we use the /Get-Features parameter. It’s important to note that we are using /Online for all of the commands here as we are operating on the current operating system and not an offline image.

dism /Online /Get-Features
Image #2 Expand

When this command is run, an output of all features and their current state is shown on screen. There are many and the default List view can be difficult to read. Thankfully there is a convenient format option that makes the output easier to parse.

dism /Online /Get-Features /Format:Table
Image #3 Expand

Now that we know what features are available, let’s pick one in particular to enable.

Get-FeatureInfo

To learn more about a specific feature, we need to use the Get-FeatureInfo option. This command requires an additional parameter as well, FeatureName that contains the name of the feature to query. In this case, we are looking for the BITS (Background Intelligent Transfer Service) feature.

dism /online /Get-FeatureInfo /FeatureName:BITS
Image #4 Expand

There are a couple of useful results returned. Notably, the Restart Required and Version properties. This is useful to know how installing the feature will affect the system and if you have the correct version. Next is enabling the feature on the system, to do that we use the Enable-Feature option.

Enable-Feature

If the feature that you want to enable has the sources already included in the operating system and is a stand-alone feature, such as BITS, then the command is very simple.

dism /Online /Enable-Feature /FeatureName:BITS
Image #5 Expand

There are a few other commands that are very useful.

Finally, perhaps it’s been decided that using BITS is not necessary, therefore we need to remove the feature from the operating system.

Disable-Feature

To simply remove a feature, it’s essentially the same as Enable-Feature but the inverse.

dism /Online /Disable-Feature /FeatureName:BITS
Image #6 Expand

There is one additional option that can be used which is /Remove. This will remove the feature but not the features manifest. This is typically used to free up space in an image. Upon installation request, a remote source would need to be specified to install the feature.

DISM Powershell Module

Using PowerShell, you can access many of the same features of DISM but in a PowerShell, object-centric, manor. Specifically, the features map as below.

Let’s quickly walk through how these features work in comparison to the standard command-line DISM tool.

You may have to import the DISM module, Import-Module DISM

Image #7 Expand

Once the module is loaded, there are many commands but we will focus on the four covered in this article.

Get-WindowsOptionalFeature

One immediate difference is that there is no Format parameter. This is because you are able to format the returned objects in any number of ways using PowerShell. The way to get a similar table view is to do the following.

Get-WindowsOptionalFeature -Online | Format-Table -AutoSize
Image #8 Expand

Next, we will want to learn more about an existing feature.

Get-WindowsOptionalFeature -FeatureName

You will notice that the cmdlet used is the same as before, but using a parameter instead. Due to how PowerShell is generally structured, this is the preferred method. To do this we will pass in the feature that we want to learn more about.

Get-WindowsOptionalFeature -Online -FeatureName BITS
Image #9 Expand

As you can see, the same information that was returned by DISM is contained in an object returned in PowerShell. Now that we have our feature to add, let’s Enable this feature.

Enable-WindowsOptionalFeature

There are several ways to use this command. The most analogous to the DISM command-line tool is the following.

Enable-WindowsOptionalFeature -Online -FeatureName BITS
Image #10 Expand

If you have a series of features or know the one you want, you can use the pipeline to pass these in. Below are two examples of how to do this.

# Pass an array of features to be enabled
@("BITS") | ForEach-Object { Enable-WindowsOptionalFeature -Online -FeatureName $_ }

# Retrieve the feature first and then Enable the feature
Get-WindowsOptionalFeature -Online -FeatureName BITS | Enable-WindowsOptionalFeature -Online

Finally, we need to disable BITS as it is no longer needed.

Disable-WindowsOptionalFeature

Just like the enable cmdlet, we simply need to pass the feature name to disable.

Disable-WindowsOptionalFeature -Online -FeatureName BITS
Image #11 Expand

Conclusion

Whether you use DISM through the command-line or through PowerShell, there is a lot of functionality available to manage Windows Features. Not only can DISM be used on a running system, but if you have offline images, it can be used to manage those as well!

The post How to use the DISM Tool to Manage Windows Features appeared first on Petri.

Exit mobile version