Powershell – Detect corrupted WMI

powershellwmi

When WMI is corrupted it will fail in the strangest ways, certain queries (most of them) will work, some will throw exceptions, others will time out and a few will simply return no (or partial/erroneous) results.

As I have a complicated important WMI system monitoring job I would like to be able to spot a corrupted WMI repository before I run the script. Determining it from the script behaviour is hard (due to the many ways WMI might fail) and often one can spend considerable time figuring out if its a system or WMI error.

I am essentially looking for a method tI can execute in the beginning of from my PowerShell script to determine beforehand if WMI is corrupted.

Best Answer

There is a script given away by Microsoft's Product Support Services team that's specifically designed to spot and diagnose corrupted WMI databases, the WMI Diagnostics Utility.

More info on how to use this at Troubleshooting WMI With WMIDiag.

Unfortunately I'm not too sure how useful this is going to be for you if you want to run this at the start of running a job, it's more the sort of thing that people tend to set to automatically run across their estate on a regular basis to report back on machines that need looking at.