Displaying WMI Inheritance

Share |

Join PowerShell.com!
Subscribe to Feed

PowerShell eBook
Sign up for
Your PowerTip of the Day:

Award-winning PowerShellPlus


Admin Guide to PowerShell Remoting


Mastering PowerShell eBook

In PowerShell 3.0, the (hidden) object property PSTypeNames shows you the complete inheritance tree for WMI objects:

PS> $os = Get-WmiObject -Class Win32_OperatingSystem

PS> $os.pstypenames
System.Management.ManagementObject#root\cimv2\Win32_OperatingSystem
System.Management.ManagementObject#root\cimv2\CIM_OperatingSystem
System.Management.ManagementObject#root\cimv2\CIM_LogicalElement
System.Management.ManagementObject#root\cimv2\CIM_ManagedSystemElement
System.Management.ManagementObject#Win32_OperatingSystem
System.Management.ManagementObject#CIM_OperatingSystem
System.Management.ManagementObject#CIM_LogicalElement
System.Management.ManagementObject#CIM_ManagedSystemElement
System.Management.ManagementObject
System.Management.ManagementBaseObject
System.ComponentModel.Component
System.MarshalByRefObject
System.Object

As you can see, the instance of Win32_OperatingSystem is derived from CIM_LogicalElement, and you can use this WMI class instead to widen your query and get back all logical elements:

PS> Get-WmiObject -Class CIM_LogicalElement | Select-Object -Property Caption, __Class 

In PowerShell 2.0, the property PSTypeNames does not include WMI inheritance information yet.

Twitter This Tip! ReTweet this Tip!


Posted Jan 29 2013, 06:00 AM by ps1
Copyright 2012 PowerShell.com. All rights reserved.