How to list all properties of a PowerShell object

后端 未结 5 898
春和景丽
春和景丽 2020-12-04 07:47

When I look at the Win32_ComputerSystem class, it shows loads of properties like Status, PowerManagementCapabilities, etc. However, when in PowerSh

5条回答
  •  -上瘾入骨i
    2020-12-04 08:09

    Try this:

    Get-WmiObject -Class "Win32_computersystem" | Format-List *
    Get-WmiObject -Class "Win32_computersystem" | Format-List -Property *
    

    For certain objects, PowerShell provides a set of formatting instructions that can affect either the table or list formats. These are usually meant to limit the display of reams of properties down to just the essential properties. However there are times when you really want to see everything. In those cases Format-List * will show all the properties. Note that in the case where you're trying to view a PowerShell error record, you need to use "Format-List * -Force" to truly see all the error information, for example,

    $error[0] | Format-List * -force
    

    Note that the wildcard can be used like a traditional wilcard this:

    Get-WmiObject -Class "Win32_computersystem" | Format-List M*
    

提交回复
热议问题