gpt4 book ai didi

Powershell:如何将列表内容输出为表格?

转载 作者:行者123 更新时间:2023-12-03 00:28:29 25 4
gpt4 key购买 nike

我有一个对象数组列表,但我想以表格格式将它们输出到控制台,就像 Get-Process 对进程所做的那样。

如何将列表输出为表格?

Format-Table 只是抛出一个错误

$bulidsList | Format-Table -Auto -InputObject $bulidsList

"The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input"

最佳答案

您在“对象的数组列表”问题中提到过。这是一个简单的测试,向您展示这些如何与 Format-Table 一起使用:

$a = @()
$a += [pscustomobject]@{a = 1; b = 2}
$a += [pscustomobject]@{a = 3; b = 4}
$a += [pscustomobject]@{a = 5; b = 6}

$a | Format-Table

这是输出:

a b
- -
1 2
3 4
5 6

关于Powershell:如何将列表内容输出为表格?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44346582/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com