从散列 table 导出到 csv 导致空值
Export from the hash table to csv results in empty values
当我导出值时,除 csv 文件的路径部分外,一切都按预期工作。他们是空白的。任何人都可以知道我的代码有什么问题吗?
$ht = @()
$files = Get-ChildItem -recurse -Filter *.xml
foreach ($file in $files) {
$path = $file.FullName
$lines = Get-Content $path
foreach ($line in $lines) {
if ($match = $ht | where {$_.line -EQ $line}) {
$match.count = $match.count + 1
$match.Paths += $path
} else {
$ht += new-object PSObject -Property @{
Count = 1
Paths = @(,$path)
Line = $line }
}
}
}
$ht
$ht.GetEnumerator() | select Count, Paths, Line | Export-Csv c:\NLG_GPO_Sort.csv
对象 属性 名为 Paths。你 select 路径。更改它以匹配。
$ht.GetEnumerator() | select Count, Paths, Line | Export-Csv c:\NLG_GPO_Sort.csv
当我导出值时,除 csv 文件的路径部分外,一切都按预期工作。他们是空白的。任何人都可以知道我的代码有什么问题吗?
$ht = @()
$files = Get-ChildItem -recurse -Filter *.xml
foreach ($file in $files) {
$path = $file.FullName
$lines = Get-Content $path
foreach ($line in $lines) {
if ($match = $ht | where {$_.line -EQ $line}) {
$match.count = $match.count + 1
$match.Paths += $path
} else {
$ht += new-object PSObject -Property @{
Count = 1
Paths = @(,$path)
Line = $line }
}
}
}
$ht
$ht.GetEnumerator() | select Count, Paths, Line | Export-Csv c:\NLG_GPO_Sort.csv
对象 属性 名为 Paths。你 select 路径。更改它以匹配。
$ht.GetEnumerator() | select Count, Paths, Line | Export-Csv c:\NLG_GPO_Sort.csv