blob: 32cd9d63efd0093693077ae7116b97a4f9cf33cb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
$logsPath = Join-Path (Get-Location).Path "_logs"
$reportFileName = '_overview.all'
$idProperty = 'Sample'
$results = $null
Get-ChildItem -Path $logsPath -Filter '*.csv' | ForEach-Object {
$csv = Import-Csv -Path $_
if ($results -eq $null) {
$results = $csv
}
else {
$results = $csv | ForEach-Object {
$id = $_.$idProperty
$match = $results | Where-Object { $_.$idProperty -eq $id }
if ($match) {
$properties = $_ | Get-Member -MemberType NoteProperty | Where-Object { $_.Name -ne $idProperty } | Select-Object -ExpandProperty Name
$newObject = New-Object PSObject
# Add ID property separately to ensure it appears first
$newObject | Add-Member -MemberType NoteProperty -Name $idProperty -Value $_.$idProperty
foreach ($property in $properties) {
$newObject | Add-Member -MemberType NoteProperty -Name $property -Value $_.$property
}
foreach ($property in ($match | Get-Member -MemberType NoteProperty | Where-Object { $_.Name -ne $idProperty } | Select-Object -ExpandProperty Name)) {
if ($properties -notcontains $property) {
$newObject | Add-Member -MemberType NoteProperty -Name $property -Value $match.$property
}
}
$newObject
}
}
}
}
$results | ConvertTo-Csv | Out-File (Join-Path $logsPath "$reportFileName.csv")
$results | ConvertTo-Html -Title "Overview" | Out-File (Join-Path $logsPath "$reportFileName.htm")
|