Latest posts by Jeffery Hicks (see all)
- Clean up user profiles with PowerShell - Mon, Jun 9 2014
- Track user logons with a PowerShell script - Fri, Jun 6 2014
- Configuring logon PowerShell scripts with Group Policy - Tue, Jun 3 2014
We’ve been looking at a number of tools for exploring WMI. The last one I want to discuss is actually a PowerShell script, but it won’t feel like any PowerShell script you’ve run before. The WMI Explorer was written back in the days of PowerShell 1.0, I believe, by former PowerShell MVP Marc van Orsouw, more familiarly known as MoW. The original home for the WMIExplorer script seems to be gone so I’ve taken the liberty of mirroring it on my blog. You can download it as a zip file. Extract the script and run it.
The script will create a Windows form and populate it with all sorts of fantastic WMI goodness. You can connect to a remote computer, but for my demonstration I’ll connect to the localhost.
Expanding the namespace tree show all available namespaces. The status bar will tell you to double-click a namespace so I’ll do so on Root\CIMv2. The script will get all classes in this namespace.
You can resize the panels as necessary as I’ve done. Scroll down to find a class that interest you and select it.
Viewing classes ^
If you hover your mouse over the class name you get a nice description, which is pulled from WMI. Or double-click the class name to populate the rest of the form.
The Help section displays information about the class and all of its properties. You can uncheck properties if you want to hide the help but I rarely find a need for that. You can also see the methods listed such as SetPowerState.
Double click on one or select the Methods tab and you’ll not only see information about the method, but also sample PowerShell code and script templates that MoW added.
Method with sample PowerShell code
You can copy and paste with the usual keyboard shortcuts. Although, remember this code was written for PowerShell 1.0 and we’ve had a number of changes since then that make it even easier to work with WMI such as Invoke-WmiMethod. Still there is a great deal of valuable reference material here.
Working with instances ^
Next, I’ll click on the Get Instances button to retrieve all instances of the current class.
This displays all properties for all instances in the tab. But you can uncheck properties above which dynamically updates the display. This makes it very easy to see the data you want.
Properties of instances
You can click on any of the column headings to sort. Or try this: double click on one of the instances to get a text listing of all properties.
Text listing of all properties
Very nice if you want to copy and paste.
WMI queries ^
Once you’ve explored a bit you might want to create a query. Under the Tools menu, click on Select Query. If you have some WMI experience you’ll know what to do with the other query types. You’ll need to fill out the form as I’ve done here. Fill in the class name and a condition then when you click Query String, the MoW PowerShell WMI Browser will automatically create it for you.
Create WMI query
To run the query, close the form, go back to Tools and select Query (Run). There shouldn’t be much more that you need to do with it.
Run a WMI query
When you close the form, the query will run and the instances tab will be updated with the results.
Updated instances tab
MoW PowerShell WMI Browser is a very nice tool for exploring WMI locally and remotely. There is no provision for alternate credentials, although if you feel up to the challenge you could edit the script to add that feature. WMI is a technology that every IT Pro should be familiar with and hopefully one or more of the tools I’ve shown you will help meet that goal.