Friday, June 15, 2018

Write Powershell Scripts Faster and easily Explore Windows Management Infrastructure Win32_Classes with WMI Code Creator utility

As a Poweshell developer your number one querying information source is the Windows Management Instrumentation (WMI), which gives you access to a wealth of management information operations on Windows-based operating systems. But WMI this has been updated to MI.

The Windows Management Infrastructure (MI) features represent the latest version of the Windows Management Instrumentation (WMI) technologies introduced in Windows 8 and Windows Server 2012 for new ways of creating Windows Management Infrastructure (MI) applications. MI is fully compatible with previous versions of WMI and provides a host of features and benefits that make designing and developing providers and clients easier. The new providers are prefixed with Win32_. 

For example, Win32_ComputerSystem inherits from the old CIM_UnitaryComputerSystem.

Win32 Provider contains 682+ classes, so how to learn about these classes quickly. 

A quick Powershell 1 liner to count Win32 classes
@(gwmi -list | where {$_.__class -match "Win32"}).Count


WMI Code Creator is a free utility from an Microsoft Technet Magazine to do just that.


Download WMI Code Creator (122KB)

Here's the WMI Code Creator GUI and how to explorer the Win32_ providers which lives under namespace "root\CIMv2".






















Want to find out what a specific field formal definition is and means ? 























Once you happy, you can now Generate Code with a Where clause by clicking "Search for Property Values" button and selecting the where value "Manufacturer=LENOVO" to appear in the Generate Code window. 

If this new code does not show up you may have to regenerate the code by selecting Code Language sub-menu with your language selection.





Press Execute Code button to get your results! 


WMI Code Creator  is a amazing toool to save you time writing administrative scripts and code. Koodos to Chris Scoville, the developer and a programming writer in the Windows Server Developer Documentation group at Microsoft.

No comments:

Post a Comment