Use WMI Code Creator to explore the details of WMI

One utility has paid incredible dividends over the past few days (not only because it is free): WMI Code Creator. This small Microsoft-provided gem allows you to explore the entire WMI namespace, and will generate code (C#, VB.Net, and VBScript) based on what you select.

If you’re using WMI, this utility goes right along-side the WMI reference documentation on MSDN in terms of usefulness.

Unit testing a WMI reboot

The other day I started working on a WMI wrapper that would encapsulate workstation management functionality (starting and stopping services, querying workstations, etc.). Unit testing, as always, is important, but I inevitably came to one problem.

How do you unit test a method that reboots a workstation?

The answer: Run the unit test, and if your machine starts to shut down, that means it’s the end of the workday, and your test passed. (It was already 6PM on a Friday, so such behavior was justified.)