powershell - Detect corrupted WMI

23
2014-07
  • Lars Tackmann

    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.

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    scripting - Powershell recursive WMI query
  • quux

    I'd like to start at the top of a WMI namespace, recurse through all the objects, then recurse through each object's property list, filtering out and returning to console only those properties that have mem in their names.

    This is what I have so far:

    gwmi -namespace "root\cimv2" -list |???? |get-Member -MemberType property | Where-Object { $_.name -match 'mem'}
    

    Notice the big |???? in the middle there. If I remove that, the the command seems to run, but fails to find properties I know should be found. Why? I think it is because I get different output from the following two commands:

    gwmi "Win32_operatingSystem"  |get-Member -MemberType property (73 lines of output)
    gwmi -namespace "root\cimv2" -list  |where-object { $_.Name -eq 'Win32_OperatingSystem' } |get-Member -MemberType property (10 lines of output)
    


    What I want is a one-liner that recursively concatenates this process:

    gwmi -namespace "root\cimv2" -list
    (manual selection of a WMI class from the list of 1000+ which appear) 
    gwmi "win32_OperatingSystem" | get-Member -MemberType property | Where-Object { $_.Definition -match 'mem' }
    

    Thanks, and if a working answer is given, I will accept and upvote it (annoying when people never do that, isn't it?).

    Note added 2009/11/14: I haven't awarded the answer yet because no one has yet provided a one-liner which solves the problem.


  • Related Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.