PowerTip: Easily Find WMI Class Schema Information with PowerShell


Summary: Use a one-line command to obtain WMI class schema (MOF) information.

Hey, Scripting Guy! Question How can I use Windows PowerShell to display the MOF of a WMI class?

Hey, Scripting Guy! Answer Use the WMIClass type accelerator, and then call the static GetText method whilst supplying the word MOF:

            ([wmiclass]”Win32_Pingstatus”).gettext(“MOF”)

Comments (4)

  1. jrv says:

    @Ed – I thought you might like it.  It dovetails with your other XML articles.

  2. jrv says:

    @ed  – good tip for investigating class structures

    Don't forget that we can turn the MOF into an Object so it is easier to create reports or other objects.

    #WMI format

    [xml]$wmidtd=(([wmiclass]"Win32_Pingstatus").gettext('WMIDtd20'))

    $wmidtd.Class

    #Cim fromat

    [xml]$Cimdtd=(([wmiclass]"Win32_Pingstatus").gettext('CimDtd20'))

    $cimdtd.Class

  3. Ed Wilson says:

    @JRV this is a really cool tip and it makes it easy to work with as well. Very nice!

  4. Ed Wilson says:

    @JRV indeed it does, like I said, "way cool"