Getting Started with DISM PowerShell Cmdlets

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.

PowerShell

1

import-moduledism

What can the module do for us?

PowerShell

1

get-command-ModuleDISM

Looks like quite a lot.

DISM PowerShell cmdlets. (Image Credit: Jeff Hicks)

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

PowerShell

1

get-command-ModuleDISM|sortNoun,Verb|format-table-GroupByNoun

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.

PowerShell

1

help Get-WindowsEdition–online

Let’s try this one.

PowerShell

1

Get-windowsedition–online

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)

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

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.

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.

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.

MEMBER LOGIN:

BECOME A PETRI MEMBER:

About the Contributor

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, teacher and consultant. Jeff has written for numerous online sites and print publications and is a frequent speaker at technology conferences and user groups. His latest book is PowerShell Scripting and Toolmaking.