使用Out-GridView,您如何控制列名?我希望列名是有意义的,而不是“string”--这可能吗?
[string] $colLabel = 'MyLabel'
[string] $a = 'a'
[string] $b = 'b'
$Selected = ($colLabel), ($a), ($b) | Out-GridView 发布于 2020-07-24 23:09:31
典型的模式是:
[pscustomobject]@{
colLabel='MyLabel'
a='a2'
b='b2'
} | Out-GridView或
get-process | select-object name,id,ws | Out-GridView下面是一个已计算属性的示例:
1 | select-object @{ n='Num'; e={$_} }
Num
---
1发布于 2020-07-24 22:23:54
当然,使用临时CSV文件:
[string] $colLabel = 'MyLabel'
[string] $a = 'a'
[string] $b = 'b'
@"
$($colLabel)`,
$($a)`,
$($b)
"@ | Set-Content temp.csv
Import-Csv temp.csv | Out-GridView
Remove-Item temp.csv首先,它创建一个临时csv文件,然后导入并传递到网格视图,然后删除它。
https://stackoverflow.com/questions/63075078
复制相似问题