The script below does not produce the path to the files in question, in my CSV file. Instead it is giving me System.Object[]. Please advise as to what I am doing wrong here.
My goal is to clean up redundant GPO's. I need to search the xml files from a GPO backup and analyze them. If I find the same custom string in two or more GPO's, the path will show me which folder contains the redundant string and can either combine the GPO's or delete one all together. Makes sense .. I hope?
$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:\temp \NLG_GPO_Sort.csv