Windows 使用PowerShell在表中格式化三个数据列表

Windows 使用PowerShell在表中格式化三个数据列表,windows,powershell,formatting,Windows,Powershell,Formatting,我有三张我想打印的号码表。这三个列表是数字的三个集合。它们有相同数量的元素,所以从这三个元素的第一个位置开始,到最后一个位置,我必须打印这样的内容 Element in list1 pos1 | Element in list2 pos1 | Element in list3 pos1 Element in list1 pos2 | Element in list2 pos2 | Element in list3 pos2 Element in list1 pos3 | El

我有三张我想打印的号码表。这三个列表是数字的三个集合。它们有相同数量的元素,所以从这三个元素的第一个位置开始,到最后一个位置,我必须打印这样的内容

Element in list1 pos1  |  Element in list2 pos1  |  Element in list3 pos1
Element in list1 pos2  |  Element in list2 pos2  |  Element in list3 pos2
Element in list1 pos3  |  Element in list2 pso3  |  Element in list3 pos3
Element in list1 pos4  |  Element in list2 pos4  |  Element in list3 pos4

...
如何使用格式表进行此操作? 或者更好,我如何使用格式表cmd let来解决这个问题


谢谢你

我是一名powershell新手,我确信有更好的方法,但我希望这个例子能帮助你

$e = @()
$a = 1,2,3,4
$b = 5,6,7,8
$c = 'nine','ten','eleven','twelve'
for ($i=0;$i -lt $a.count;$i++) {
$d = New-Object PSObject -Property @{            
        one       = $a[$i]
        two       = $b[$i]
        three     = $c[$i]
  }      
$e+=$d}
$e | select one,two,three | ft -auto
这里有一个解决方案:

$c0=357,380,45
$c1=12,20,410
$c2=223,270,30

0..($c0.Length -1) | 
       select-object (
           @{n="one";   e={$c0[$_]}},
           @{n="two";   e={$c1[$_]}},
           @{n="three"; e={$c2[$_]}}
              ) | 
       format-table -auto;
结果:

one two three
--- --- -----
357  12   223
380  20   270
 45 410    30

解释

@{n=“blah”;e={blah}}的每个实例都是一个哈希表。这些键是“名称”和“表达式”的缩写。参见示例4


“$”表示正在导入的值。在这种情况下,每个索引值都通过管道传输到select语句。

您能解释一下您的操作吗?我认识到一些类似于创建关联数组的东西。。。。关于@oerator???的帽子????谢谢你
 $c0 = 357,380,45
 $c1 = 12,20,410
 $c2 = 223,270,30

 $x = foreach ($i in 0..(($c0.count)-1)){
 ($c0[$i],$c1[$i],$c2[$i]) -join "," | convertfrom-csv -header "c0","c1","c2" 
 } 

 $x | ft -auto

 c0  c1  c2 
 --  --  -- 
 357 12  223
 380 20  270
 45  410 30