From 0a566649e41dc8664ea4b3c61d5b72bb426f2d8c Mon Sep 17 00:00:00 2001 From: Nik Charlebois Date: Wed, 4 Jan 2023 09:56:33 -0500 Subject: [PATCH] Fixes #2715 --- CHANGELOG.md | 2 + .../Modules/M365DSCReport.psm1 | 45 +++++++++++++++++-- 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 190d86a928..bee8290771 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,8 @@ * Added support to generate parameter descriptions automatically from schema FIXES [#2720](https://github.com/microsoft/Microsoft365DSC/issues/2720) * MISC + * Fixes an issue where OrderedDictionary values weren't properly expanded in a delta report + FIXES [#2715](https://github.com/microsoft/Microsoft365DSC/issues/2715) * Updated website generation code to checkout correct commit # 1.22.1221.1 diff --git a/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 index f07a0cd42a..3868259344 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1 @@ -1093,13 +1093,52 @@ function New-M365DSCDeltaReport $emoticon = '🟦' } + $sourceValue = $drift.ValueInSource + $destinationValue = $drift.ValueInDestination + $CIMType = $drift.ValueInSource[0].CimInstance + + if ($sourceValue.GetType().Name -eq 'Object[]' -and -not [System.String]::IsNullOrEmpty($CIMType)) + { + $sourceValue = "" + $orderedKeys = $drift.ValueInSource.Key | Sort-Object + + foreach ($key in $orderedKeys) + { + $currentValue = ($drift.ValueInSource | Where-Object -FilterScript {$_.Key -eq $key}).Value + $sourceValue += "" + $sourceValue += "" + $sourceValue += "" + $sourceValue += "
$CIMType
$key = $currentValue

" + } + $sourceValue = $sourceValue.Substring(0, $sourceValue.Length -5) + $cellStyle = "vertical-align:top;" + } + + if ($destinationValue.GetType().Name -eq 'Object[]' -and -not [System.String]::IsNullOrEmpty($CIMType)) + { + $destinationValue = "" + $orderedKeys = $drift.ValueInDestination.Key | Sort-Object + $CIMType = $drift.ValueInDestination[0].CimInstance + + foreach ($key in $orderedKeys) + { + $currentValue = ($drift.ValueInDestination | Where-Object -FilterScript {$_.Key -eq $key}).Value + $destinationValue += "" + $destinationValue += "" + $destinationValue += "" + $destinationValue += "
$CIMType
$key = $currentValue

" + } + $destinationValue = $destinationValue.Substring(0, $destinationValue.Length -5) + $cellDestinationStyle = "vertical-align:top;" + } + [void]$reportSB.AppendLine('') [void]$reportSB.AppendLine("") [void]$reportSB.AppendLine("$($drift.ParameterName)") [void]$reportSB.AppendLine("") - [void]$reportSB.AppendLine("$($drift.ValueInSource)") - [void]$reportSB.AppendLine("") - [void]$reportSB.AppendLine("$($drift.ValueInDestination)") + [void]$reportSB.AppendLine("$($sourceValue)") + [void]$reportSB.AppendLine("") + [void]$reportSB.AppendLine("$($destinationValue)") [void]$reportSB.AppendLine('') if ($null -ne $drift._Metadata_Level)