Summary: Explore and discover the additional Windows PowerShell modules in Windows 8.1.
Honorary Scripting Guy, Sean Kearney, is here this week to go where no Scripter has boldly gone before! Into the modules that are often overlooked in Windows 8.1!
Yesterday we saw that Windows PowerShell allows you to manage settings for search and for Windows Defender. These settings could even be stored from machine to machine in an XML file to set up standard configurations in a peer-to-peer environment. For more, see Windows 8.1 and the Land of Forgotten Modules: Part 1.
Today we’ll look at a module that’s been a long time in the waiting: DISM. Most of us new to deploying Windows may not be aware of the Power held by DISM. The DISM Module is the modern day version of DISM.EXE or the “Deployment Image Servicing and Management” application.
DISM does a lot (and I mean an awful lot) of really cool things. I can use DISM to turn features on and off in my Windows environment. And I can use it to capture a Windows computer as a base image!
So let’s crack open that module and see how many cmdlets it has in there for me to get into trouble w…
I mean, for me to use…
Right…right, that’s the ticket!
Look at some of those names and let your mind wander as to what you could do with this module.
With the free Hyper-V lab and Windows PowerShell, we can use the Get-WindowsImage cmdlet to get a list of images in an Install.wim file:
Get-WindowsImage –ImagePath D:\Sources\Install.wim
But one of the cool features that I like to use DISM for is getting and enabling features in Windows 8.1. In the server world, we get spoiled with the Get-WindowsFeature cmdlet. But there’s nothing stopping us from doing the same thing in Windows 8.1 when we have DISM. We can use the Get-WindowsOptionalFeature cmdlet:
Get-WindowsOptionalFeature –online | Format-Table
This will display all of the enabled and disabled features in Windows. The names are not quite as nice as the big server cousin names, but most make plain and simple sense. It also works in a similar manner.
I can enable the built-in IIS web server for my developer friend by using this command:
Enable-WindowsOptionalFeature –online –Featurename IIS-WebServerRole
Or I can be the mean Mr. Script and take away the Media Player from an employee:
Remove-WindowsOptionalFeature –online –Featurename WindowsMediaPlayer
Here’s a simple piece. If for any reason you needed to change the product key in your copy of Windows, you can do that too:
Set-WindowsProductKey –online –productkey ‘AAAAA-BBBBB-CCCCC-DDDDD-EEEEE’
But you want to make sure your key lines up with the edition of Windows you’re running. You can check that without going to the GUI:
You’ll notice that in many of these commands that use the DISM Module, I reference the -online parameter. This is because you can use the DISM Module to turn on and off features (in addition to adding and manipulating drivers) in your base Windows image files (WIM).
With DISM.EXE we could do a lot of this before, but now everything is returned as objects. So I can pipe the data to a table on the screen, capture it as a CSV file, or simply run Get-Member against it to see what kinds of information are available. Which I find it far easier to use! Because as with everything in Windows PowerShell, the answer is only a Get-Help away!
I’ll see you tomorrow as we wander further along the module neighborhood!
I invite you to follow The Scripting Guys on Twitter and Facebook. If you have any questions, send an email to The Scripting Guys at email@example.com, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then remember eat your cmdlets each and every day with a taste dash of creativity.
Sean Kearney, Windows PowerShell MVP and Honorary Scripting Guy