none
PowerShell WMI Class Tree View RRS feed

  • Question

  • I loved the old WMI Browser that you could see the WMI Classes in an inheritance tree view. This made it easy to go up and down the tree finding similar things.

    Can you write a PowerShell script that would list the classes in an inheritance tree?

    Thanks,
    SLDR
    (Stephen L. De Rudder)

    Sorry, I didn't make the question clear (forgot question mark).

    Note: I am looking for something that will create the list of CIM classes in an inheritance tree view like the WMI Browser did. The problem I am having is that I can't seem to find a way to traverse the inheritance tree starting from the top and going down (ie: CIM_Chip -> CIM_PhysicalMemory -> Win32_PhysicalMemory). What I need is a way to get all classes that inherit from a specific class. I can go from the bottom up by getting the superclass with the "__SUPERCLASS" property then get the superclass of that class repeatedly to finely find the root class.

    I realize I could take each class from Get-CimClass and construct an inheritance tree starting from the bottom and working my way up till class is the root but that it not optimal.

    • Edited by SLDR Friday, December 6, 2013 3:53 PM Call out the questiion and add more details of what I am after.
    Thursday, December 5, 2013 8:58 PM

Answers

All replies

  • Hi

    check this doc

    http://powershell.com/cs/blogs/tips/archive/2013/01/29/displaying-wmi-inheritance.aspx


    Romeo Donca, Orange Romania (MCSE, MCITP, CCNA) Please Mark As Answer if my post solves your problem or Vote As Helpful if the post has been helpful for you.

    Thursday, December 5, 2013 9:07 PM
  • What's your question?

    There are WMI browsers freely available.

    Bill

    Thursday, December 5, 2013 9:08 PM
    Moderator
  • I loved the old WMI Browser that you could see the WMI Classes in an inheritance tree view. This made it easy to go up and down the tree finding similar things. Can you write a PowerShell script that would list the classes in an inheritance tree.

    Thanks,
    SLDR
    (Stephen L. De Rudder)

    Sapien has a WMI browser built with PowerShell

    http://www.sapien.com/blog/2013/07/29/introducing-the-wmi-explorer-2014/

    It is quite an awesome tool.


    ¯\_(ツ)_/¯

    • Marked as answer by SLDR Wednesday, December 17, 2014 11:20 PM
    Thursday, December 5, 2013 9:21 PM
  • Thought this may be helpful too, based on the new CIM cmdlets:

    Getting WMI IntelliSense

    Thursday, December 5, 2013 10:08 PM
  • One note.  The last time I tried it Scriptomatic won't work on Windows 7 and later. There is a fix but I forget what it was.

    ¯\_(ツ)_/¯

    Thursday, December 5, 2013 10:21 PM
  • Fixed it. I should have been more clear too. Thanks for point it out.
    Friday, December 6, 2013 3:55 PM
  • Fixed it. I should have been more clear too. Thanks for point it out.

    Fixed what?  Is your question answered now?


    ¯\_(ツ)_/¯

    Friday, December 6, 2013 4:31 PM
  • Bill asked what my question is. I fixed my question to be a question. And gave more details about what I was looking for.
    Friday, December 6, 2013 6:04 PM
  • Bill asked what my question is. I fixed my question to be a question. And gave more details about what I was looking for.

    So you are saying that you are asking a different question and that it has not been answered.

    The question you are now asking has no answer.  There is no tool to do what you ask and , as far as I knw, there has never been a tool like that.

    The relations in classes are only tattooed in one direction.  This is true of ALL class hierarchies.

    Are you sure you are not trying to look up "associations" and relationships".  There are queries and methods to return those.

    An association is a child of sibling that describes the details of an instance.

    Look into "AssociatorsOf" and in PowerSHell <instance>.GetRelated() and <instance>.GetRelationShips()

    This is how we do a look around for other objects and configurations.

    You can also dump the WMI laded object database but it requires using a C/C++ program to make the calls and handle the structures.  It can also be done with C# and VB.Net.  I am pretty sure it cannot be done with VBScript.

    You could also foreseeably load all of the MOFs into a database and query them.  This would be as hard as creating a reverse lookup database by walking very object back.

    We can do this by loading every class name and parent into a table and use the "parent" field to create a linked list.  This can thenbeeasily queried with SQL to obtain a binary tree.  There ae also issues with tis sort of this.  Many classes are what is called a "formal" class and are used to creat other objects.  They will clog up the works if not identified.


    ¯\_(ツ)_/¯

    Friday, December 6, 2013 6:50 PM
  • Here is current code to browse the schema:

    http://msdn.microsoft.com/en-us/library/aa719643(v=vs.71).aspx


    ¯\_(ツ)_/¯

    Friday, December 6, 2013 6:52 PM
  • The class browser from Sapien is currently the best way to browse a hierarchy of classes in WMI.  It has been around for years and is free.

    There is an earlier version available that was built by MOWW.

    You can also just do this for all classes in a loop into a table.

    CimClass  * -Namespace root/CIMV2 -Verbose |select CimClassName, CimSuperClassName


    ¯\_(ツ)_/¯


    • Edited by jrv Friday, December 6, 2013 7:28 PM
    Friday, December 6, 2013 7:27 PM
  • Get-WmiObject can do tis recursively through all namespaces

    gwmi -list * -rec -ns root |select __CLASS, __SUPERCLASS


    ¯\_(ツ)_/¯

    Friday, December 6, 2013 7:31 PM
  • Brian the "Brain" keeps reminding use that he, too, has a great browser.

    Check it out!

    See: https://gallery.technet.microsoft.com/PowerShell-Object-Browser-847d62c1


    ¯\_(ツ)_/¯


    • Edited by jrv Wednesday, December 17, 2014 11:36 PM
    Wednesday, December 17, 2014 11:36 PM
  • I put together a little visualization. It might be useful to someone learning WMI and trying to visualize how everything fits together in the class inheritance. http://kreelbits.blogspot.com/2018/09/wmi-rootcimv2-hierarchy-visualization.html

    Wednesday, September 19, 2018 6:49 PM