WMI Control in Windows Vista

WMI (Windows Management Instrumentation) offers a ton of data about a Windows computer. It is a open database of information that Microsoft and others populate with virtually all details regarding your system. While management software can (and often does) take advantage of this data collection, it is also very easy to get at this information from scripts.

There are a number of WMI script generators out there including Microsoft’s Script-O-Matic and other copycat tools. One worth mentioning is provided as the “WMI Wizard” in the “Admin Script Editor” (www.adminscripteditor.com) tool. A couple of unique things it does includes generating script code in PowerShell, VBScript, KiXtart or AutoIt scripting languages and showing sample values for selected properties. The latter is important because while you may see something that looks like just what you want when browsing about, all too often the value is either unpopulated or unfriendly (unreadable that is). The feature is fully functional in the 45 day trial available for download.

You can control WMI from the WMI Control snap-in in the MMC.

1) Hit the “Start” button, type MMC and hit enter
2) If you have UAC enabled, you’ll have to answer the prompt that this is okay to run
3) Under file click “Add/Remove Snapin…” and then choose the WMI Control snapin at the bottom of the list provided.
4) You’ll be given the option to manage this on your local system or a remote one (I choose local)
5) Unlike many MMC snapins this is actually a separate dialog so all you get in the tree is a single node with no child nodes. Right click it and choose “Properties” to get at its settings.

The general tab shows you some basic information pulled from WMI regarding your system. Probably nothing you didn’t know here. The Backup/Restore tab lets you do as you’d expect. With the Security tab we finally get to something interesting. Here you can specify security on any level similar to how you would on most other items such as files and folders. Finally, there is an “Advanced” tab which has but one setting and that is to allow for you to specify the default namespace for purposes of scripting. This is set to root\cimv2 by default and is not something you would normally change as this is where most of the classes exist that pertains to your system. With this set, you need not specify the full path to the namespace when referencing a class as in the example below.

PowerShell:

foreach ($wmiColl in Get-WmiObject Win32_BIOS *){
Write-Output ("SerialNumber: " + $wmiColl.SerialNumber)
}

In the above example I’m just getting the Asset Tag code from the system BIOS. All data returned from WMI is provided as a collection, so even when you know there is one result it is necessary to address it this way. For example if you were looking for drive information, each collection would provide information on a different drive and there could be any number of drives returned depending on the system. Here it makes sense, but just keep in mind the rule is the same for when you know there is only one response

Comments :

0 comments to “WMI Control in Windows Vista”