29 April 2010

Managing Windows 7 Deployment with DISM

Using DISM to configure Windows 7


Starting DISM

The first thing we need to do in order to run DISM is have an elevated command prompt open.
Simply going Start –> Run –> cmd –> Enter won’t do the trick as that runs with user privileges.
What we need to do is either do Start –> Run –> Cmd –> Shift+CTRL+Enter
or Click on Start type cmd and when it appear in the search box, right click on it and choose “Run as Administrator”:



Once we’ve got the elevated command prompt open
– we can check this by looking in the task bar and the title should be prefixed by “Administrator: “



Now if we type “dism” we should get help about dism. If you get the message:

Error: 740

Elevated permissions are required to run DISM.
Use an elevated command prompt to complete these tasks.

Then you didn’t successfully get a command prompt with elevated privileges open.



Finding Basic Information With DISM

Now that we’ve got our command prompt ready for action, we can find some basic information about the OS we’re currently running. At the prompt type:

dism /online /Get-CurrentEdition

This tells dism we want to use the current version (/online) and the command – similar to PowerShell – tells dism we want to get information about the current edition (/Get-CurrentEdition). Proving successful the results should return something like:

Deployment Image Servicing and Management tool
Version: 6.1.7100.0

Image Version: 6.1.7100.0

Current edition is:

Current Edition : Ultimate

The operation completed successfully.

Now let’s take it one step further. As there are different versions of Windows 7 available, we have the potential to upgrade. If we run dism (referencing the online image - /online) with /Get-TargetEditions, it will tell us what versions we can upgrade to (if at all possible). So, if I run

dism /online /Get-TargetEditions

against a machine that is already running Windows 7 Ultimate, DISM should return:

Deployment Image Servicing and Management tool
Version: 6.1.7100.0

Image Version: 6.1.7100.0

Editions that can be upgraded to:

(The current edition cannot be upgraded to any target editions.)

The operation completed successfully.

So, scripting the above can prove useful if we need to interrogate or find information about our existing machine or its capabilities.

Changing the System with DISM

As well as querying the system for information, one of the most powerful features of DISM is its capability to “service” an “online” or live image. This allows us the capability to change the OS on the fly. For example, Windows 7 ships with numerous games and features installed that we might not want as part of our corporate build. Using the functionality built in to DISM – whilst the OS is running – we can remove these features.

First, let’s look at what is installed and what we can change. To do this, at the prompt we need to type:

dism /online /Get-Features | more

Again, we reference the current version (/online) and we use the command /Get-Features to show us the currently installed features. The “| more” simply paginates the output so we can see it without having to scroll. If we look through the list some of the features we want to remove can be seen:

….

Feature Name : FreeCell
State : Enabled

Feature Name : Minesweeper
State : Enabled

Feature Name : PurblePlace
State : Enabled

….

As the state of these currently shows “Enabled” we want to remove or disable them. Using DISM, we can easily do this. At the prompt we can type:

dism /online /Disable-Feature /FeatureName:

Where we simply replace with the feature from the list of results we got using /Get-Features. NOTE: The features are CaSe SEnSItivE. As an example, if we wanted to remove PurblePlace, we could simply enter:

dism /online /Disable-Feature /FeatureName:PurblePlace

at which time DISM will kick in and should return results like the following:

Deployment Image Servicing and Management tool
Version: 6.1.7100.0

Image Version: 6.1.7100.0

Disabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Let’s now check to see if it was disabled:

dism /online /Get-FeatureInfo /FeatureName:PurblePlace

Deployment Image Servicing and Management tool
Version: 6.1.7100.0

Image Version: 6.1.7100.0

Feature Information:

Feature Name : PurblePlace
Display Name : Purble Place
Description : Purble Place
Restart Required : Possible
State : Disabled

Custom Properties:

(No custom properties found)

The operation completed successfully.

As we can see “State : Disabled” means we’ve disabled it. Should we want to re-enable it, we can simply type:

dism /online /Enable-Feature /FeatureName:PurblePlace

At which time DISM will put the feature back on the machine in a similar way it removed it:

Deployment Image Servicing and Management tool
Version: 6.1.7100.0

Image Version: 6.1.7100.0

Enabling feature(s)
[==========================100.0%==========================]
The operation completed successfully.

Conclusion

As you can see DISM is a very powerful tool and the introduction of online/live servicing makes it even more useful to the IT professional. To get more information about DISM or any of its functions or capabilities, use the /? flag when you get stuck. Some examples include:

“dism /?” – which will tell you about the root level capabilities
“dism /online /?” – which will tell you about the online image servicing capabilities
“dism /online /Get-Features /?” – which will tell you about the Get-Features function
And from there, the sky’s the limit. Happy DISM’ing.

No comments:

Post a Comment