Getting Started with DISM PowerShell Cmdlets

Posted on June 3, 2015 by Jeff Hicks in PowerShell with 0 Comments

For a while now IT pros have used the command-line tool DISM.EXE to manage Windows images and installations, which isn’t an especially difficult tool to use. Because it is a command line tool, everything it outputs is text, and this can make it tricky if you are trying to do anything with it. Fortunately, Windows 8 brought us a new module, conveniently called DISM. Let me introduce you to it and use some of the commands to adjust my desktop settings.

DISM isn’t required anymore because PowerShell automatically imports modules when you use one of its commands. But you probably don’t know what those commands are called, so we’ll go ahead and explicitly import the module.

What can the module do for us?

Looks like quite a lot.

DISM PowerShell cmdlets. (Image Credit: Jeff Hicks)

DISM PowerShell cmdlets. (Image Credit: Jeff Hicks)

Perhaps we should organize the results into something easier to read.

DISM PowerShell cmdlets. (Image Credit: Jeff Hicks)

DISM PowerShell cmdlets. (Image Credit: Jeff Hicks)

All of these commands should have full help, which I’ll leave to you to read. Don’t forget you can also get online help as well.

Let’s try this one.

The get-windowsedition cmdlet. (Image Credit: Jeff Hicks)

The get-windowsedition cmdlet. (Image Credit: Jeff Hicks)

I don’t have a need to change my current edition, so let’s look at optional features. You can manually set them via the Control Panel under Programs.

Programs and features dialog. (Image Credit: Jeff Hicks)

Programs and features dialog. (Image Credit: Jeff Hicks)

Sponsored

This leads you to different options for turning Windows features on or off.

Turn Windows features on or off. (Image Credit: Jeff Hicks)

Turn Windows features on or off. (Image Credit: Jeff Hicks)

Instead, let’s use PowerShell and some of the DISM cmdlets. I know from looking at commands earlier that there is something that’s a good candidate. After reading help, I give it a try.

The get-windowsoptionalfeature cmdlet in Windows PowerShell. (Image Credit: Jeff Hicks)

The get-windowsoptionalfeature cmdlet in Windows PowerShell. (Image Credit: Jeff Hicks)

Now that I see what the output is like, you can also re-run the command and pipe to Get-Member to discover property names. Now, I can easily find optional features I haven’t installed yet.

The get-windowsoptionalfeature cmdlet in Windows PowerShell. (Image Credit: Jeff Hicks)

The get-windowsoptionalfeature cmdlet in Windows PowerShell. (Image Credit: Jeff Hicks)

In the list is the Telnet client, which could come in handy as a troubleshooting tool.

The Telnet Client allows you to connect to other computers remotely. (Image Credit: Jeff Hicks)

The Telnet Client allows you to connect to other computers remotely. (Image Credit: Jeff Hicks)

Looks good to me. I need to enable it. Looking back in the list of commands, I saw an Enable-WindowsOptionalFeature cmdlet. Again, after reading help this should enable the feature.

This particular feature installs quickly and doesn’t require a reboot.

The Enable-WindowsOptionalFeature cmdlet. (Image Credit: Jeff Hicks)

The Enable-WindowsOptionalFeature cmdlet. (Image Credit: Jeff Hicks)

And sure enough it is now installed.

The Telnet client has successfully installed. (Image Credit: Jeff Hicks)

The Telnet client has successfully installed. (Image Credit: Jeff Hicks)

While I’m at it, let me check the status of the optional Windows PowerShell 2.0 feature. I’m not sure what the feature is called, but fortunately I can use wildcards.

Scrolling down I see the features.

I want to remove the highlighted features. Let’s refine my wildcard pattern and disable the matching features.

Disabling matching features. (Image Credit: Jeff Hicks)

Disabling matching features. (Image Credit: Jeff Hicks)

Done! I can even verify by trying to start a v2 session.

Mission accomplished! Should I find the need to re-enable it, I can re-run the previous command and use Enable-WindowsOptionalFeature. All of this is so much faster than navigating through the GUI under Control Panel.

Sponsored

There are a few caveats. The Enable and Disable cmdlets don’t support –WhatIf or –Confirm, although I wish they would. Technically, I believe they should support these parameters because you are changing the state of the system. That is why it is very important to read cmdlet help. And if you intend to try out the DSM cmdlets, I strongly encourage you to use a test computer, preferably virtualized so that you can easily rollback changes, should things get out of hand.

Sponsored

Tagged with , , , ,