如何列出 PowerShell 对象的所有属性 [英] How to list all properties of a PowerShell object

查看:80
本文介绍了如何列出 PowerShell 对象的所有属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我查看 Win32_ComputerSystem 类时,它显示了很多属性,如 StatusPowerManagementCapabilities 等.但是,当我在 PowerShell 中执行以下操作时,我只会得到几个:

When I look at the Win32_ComputerSystem class, it shows loads of properties like Status, PowerManagementCapabilities, etc. However, when in PowerShell I do the below I only get back a couple:

PS C:\Windows\System32\drivers> Get-WmiObject -Class "Win32_computersystem"

Domain              : YYY.com
Manufacturer        : VMware, Inc.
Model               : VMware Virtual Platform
Name                : LONINEGFQEF58
PrimaryOwnerName    : Authorised User
TotalPhysicalMemory : 2147016704

如何查看所有属性?

推荐答案

试试这个:

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

对于某些对象,PowerShell 提供了一组可以影响表格或列表格式的格式说明.这些通常是为了将大量属性的显示限制为仅显示基本属性.然而,有时候你真的很想看到一切.在这些情况下,Format-List * 将显示所有属性.注意,在尝试查看PowerShell错误记录的情况下,需要使用Format-List * -Force"才能真正看到所有错误信息,例如

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*

这篇关于如何列出 PowerShell 对象的所有属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆