2017-10-17 68 views
0

我有两个文本文件,比方说含有:PowerShell的:OUT-GridView控件与文本文件

的1.txt:

1 
2 
3 
4 
5 
6 

2.txt:

a 
b 
c 
d 
e 
f 

我尝试读取文件,然后将结果输出到Out-Gridview(每个文件位于其自己的列中):

1 a 
2 b 
3 c 
4 d 
5 e 
6 f 

我想:

$list1= gc 1.txt 
$list2= gc 2.txt 



$list1 | Add-Member -Name "LIST 2" -MemberType NoteProperty -Value $liste2 


$list1 | out-gridview -wait 

但我得到的是:

enter image description here

我怎么能读,然后输出到GridView的列,每列的文本文件?非常感谢你,我不知道这一点......

回答

0

当你只有两列时创建一个散列表。 就像是:

$a = 1,2,3,4 
$b = "a","b","c","d" 
$hashtable = @{} 

for($i = 0;$a.Count -gt $i;$i++){ 
    $hashtable.Add($a[$i],$b[$i]) 
} 

$hashtable | Out-GridView 

,如果你有两个以上的列,创建自定义对象

+0

谢谢,我已经决定要使用不同的方式,但是这是有帮助的! – Rakha