我有一个对象数组列表,但我想将它们以表格格式输出到控制台,就像Get-Process进程一样。
如何将列表输出为表格?
Format-Table 只是抛出一个错误
$bulidsList | Format-Table -Auto -InputObject $bulidsList
Run Code Online (Sandbox Code Playgroud)
“输入对象无法绑定到命令的任何参数,因为该命令不采用管道输入,或者输入及其属性与采用管道输入的任何参数都不匹配”
您在问题“对象的数组列表”中提到。这是一个简单的测试,向您展示如何与 Format-Table 一起使用:
$a = @()
$a += [pscustomobject]@{a = 1; b = 2}
$a += [pscustomobject]@{a = 3; b = 4}
$a += [pscustomobject]@{a = 5; b = 6}
$a | Format-Table
Run Code Online (Sandbox Code Playgroud)
这是输出:
a b
- -
1 2
3 4
5 6
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
22257 次 |
| 最近记录: |