I ran across the need today to display all the properties of each Win32_* WMI object. To cut to the chase, this is what worked (thanks to /\/\o\/\/) for a bit of help simplifying this:
gwmi -list | where {$_.__class -match "Win32"} |
select @{n=’WmiName’;e={$_.name}} ,
@{n=’Properties’;e={$_.psbase.properties}} |
select WmiName -expand Properties |
format-table Name,Type -groupby WmiName
select @{n=’WmiName’;e={$_.name}} ,
@{n=’Properties’;e={$_.psbase.properties}} |
select WmiName -expand Properties |
format-table Name,Type -groupby WmiName
This results in output like this:
WmiName: Win32_ComputerSystemEvent
Name Type
—- —-
MachineName String
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
—- —-
MachineName String
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
WmiName: Win32_ComputerShutdownEvent
Name Type
—- —-
MachineName String
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
Type UInt32
—- —-
MachineName String
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
Type UInt32
WmiName: Win32_SystemTrace
Name Type
—- —-
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
—- —-
SECURITY_DESCRIPTOR UInt8
TIME_CREATED UInt64
The one basic trick here is that you need to access the raw ManagementClass object via the "psbase" property in order to access the "Properties" property. The PSBase property is available on all .NET objects within PowerShell because PowerShell adapts all .NET objects to PowerShell by creating a wrapper object around the .NET object.