fix: Fixed merging and added date to columns without a status
This commit is contained in:
@@ -26,6 +26,9 @@ function Merge-CISExcelAndCsvData {
|
|||||||
$AuditResults
|
$AuditResults
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Extract recommendation numbers from the CSV
|
||||||
|
$csvRecs = $csvData | Select-Object -ExpandProperty Rec
|
||||||
|
|
||||||
# Ensure headers are included in the merged data
|
# Ensure headers are included in the merged data
|
||||||
$headers = @()
|
$headers = @()
|
||||||
$firstItem = $import[0]
|
$firstItem = $import[0]
|
||||||
@@ -36,11 +39,13 @@ function Merge-CISExcelAndCsvData {
|
|||||||
|
|
||||||
$mergedData = @()
|
$mergedData = @()
|
||||||
foreach ($item in $import) {
|
foreach ($item in $import) {
|
||||||
$csvRow = $csvData | Where-Object { $_.Rec -eq $item.'recommendation #' }
|
# Check if the recommendation number exists in the CSV
|
||||||
if ($csvRow) {
|
$recNum = $item.'recommendation #'
|
||||||
|
if ($csvRecs -contains $recNum) {
|
||||||
|
$csvRow = $csvData | Where-Object { $_.Rec -eq $recNum }
|
||||||
$mergedData += New-MergedObject -ExcelItem $item -CsvRow $csvRow
|
$mergedData += New-MergedObject -ExcelItem $item -CsvRow $csvRow
|
||||||
} else {
|
} else {
|
||||||
$mergedData += New-MergedObject -ExcelItem $item -CsvRow ([PSCustomObject]@{Connection=$null; Status=$null; Date=$null; Details=$null; FailureReason=$null})
|
$mergedData += $item
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,7 +35,8 @@ function Update-CISExcelWorksheet {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Update the worksheet with the provided data
|
# Update the worksheet with the provided data
|
||||||
Update-WorksheetCell -Worksheet $worksheet -Data $Data -StartingRowIndex $StartingRowIndex
|
$validRows = $Data | Where-Object { $_.'recommendation #' -ne $null }
|
||||||
|
Update-WorksheetCell -Worksheet $worksheet -Data $validRows -StartingRowIndex $StartingRowIndex
|
||||||
|
|
||||||
# Save and close the Excel package
|
# Save and close the Excel package
|
||||||
Close-ExcelPackage $excelPackage
|
Close-ExcelPackage $excelPackage
|
||||||
|
Reference in New Issue
Block a user