我想使用Format-Table -Autosize和pscustomobject。
我想要相当于:
Get-Process | ft Id,ProcessName -AutoSize我试过了(尽管输出位于中间)
Get-Process | %{
[pscustomobject]@{
ID = $_.Id
ProcessName = $_.ProcessName
}
}它可以工作,但是当我使用Format-Table -Autosize时,它不起作用,它用新的行添加了新的标题。
Get-Process | %{
[pscustomobject]@{
ID = $_.Id
ProcessName = $_.ProcessName
} | Format-Table -AutoSize
}如何解决这个问题?
发布于 2015-05-20 15:27:45
你的烟斗在错误的位置。
Get-Process | %{
[pscustomobject]@{
ID = $_.Id
ProcessName = $_.ProcessName
}
} | Format-Table -AutoSize您告诉它为每个元素输出一个表,而不是按预期使用管道。
发布于 2015-05-20 15:27:38
您在错误的地方向Format-Table输送管道:
Get-Process | % {
[pscustomobject]@{
ID = $_.Id
ProcessName = $_.ProcessName
}
} | Format-Table -AutoSizehttps://stackoverflow.com/questions/30353988
复制相似问题