Skip to content

Commit

Permalink
Update M365DSCReport.psm1
Browse files Browse the repository at this point in the history
  • Loading branch information
NikCharlebois committed Apr 21, 2023
1 parent 52ef0d4 commit f0c0fc1
Showing 1 changed file with 52 additions and 4 deletions.
56 changes: 52 additions & 4 deletions Modules/Microsoft365DSC/Modules/M365DSCReport.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,7 @@ function Compare-M365DSCConfigurations
$drift = $null
foreach ($destinationResourceInstance in $destinationResourceInstances)
{
$foundResourceMatch = $true
foreach ($property in $instance.Keys)
{
if ($null -ne (Compare-Object -ReferenceObject ($instance."$property")`
Expand All @@ -599,9 +600,10 @@ function Compare-M365DSCConfigurations
ValueInDestination = $destinationResourceInstance."$property"
})
}
$foundResourceMatch = $false
}
}
if ($null -eq $drift)
if ($foundResourceMatch)
{
$foundOneMatch = $true
}
Expand Down Expand Up @@ -1461,30 +1463,76 @@ function New-M365DSCDeltaReport
# We have detected the drift in a CIMInstance
if ($drift.ContainsKey("CIMInstanceKey"))
{
if ($null -ne $drift.ValueInSource)
if ($null -ne $drift.ValueInSource -and $null -ne $drift.ValueInDestination)
{
$sourceValue = "<table width = '100%'>"
$sourceValue += "<tr><th colspan='2' width='100%' style='border:1px solid black; text-align:middle;background-color:#CCC'>$($drift.CimInstanceKey) = '$($drift.CIMInstanceValue)'</th></tr>"
$valueForSource = $drift.ValueInSource
$sourceValue += "<tr><td style='border:1px solid black; text-align:right;'>$($drift.ParameterName)</td><td style='border:1px solid black;'>$valueForSource</td>"
$sourceValue += "</table>"
}
elseif ($null -ne $drift.ValueInSource -and $null -eq $drift.ValueInDestination)
{
$sourceValue = "<table width = '100%'>"
$sourceValue += "<tr><th colspan='2' width='100%' style='border:1px solid black; text-align:middle;background-color:#CCC'>$($drift.CimInstanceKey) = '$($drift.CIMInstanceValue)'</th></tr>"

if ($drift.ValueInSource.GetType().Name -ne 'OrderedDictionary')
{
$valueForSource = $drift.ValueInSource
$sourceValue += "<tr><td style='border:1px solid black; text-align:right;'>$($drift.ParameterName)</td><td style='border:1px solid black;'>$valueForSource</td>"
}
else
{
foreach ($key in $drift.ValueInSource.Keys)
{
if ($key -ne 'CIMInstance')
{
$valueForSource = $drift.ValueInSource.$key
$sourceValue += "<tr><td style='border:1px solid black; text-align:right;'>$key</td><td style='border:1px solid black;'>$valueForSource</td>"
}
}
}
$sourceValue += "</table>"
}
else
{
$sourceValue += "&nbsp"
}

if ($null -ne $drift.ValueInDestination)
if ($null -ne $drift.ValueInDestination -and $null -ne $drift.ValueInSource)
{
$destinationValue = "<table width = '100%'>"
$destinationValue += "<tr><th colspan='2' width='100%' style='border:1px solid black; text-align:middle;background-color:#CCC'>$($drift.CimInstanceKey) = '$($drift.CIMInstanceValue)'</th></tr>"
$valueForDestination = $drift.ValueInDestination
$destinationValue += "<tr><td style='border:1px solid black; text-align:right;'>$($drift.ParameterName)</td><td style='border:1px solid black;'>$valueForDestination</td>"
$destinationValue += "</table>"
}
elseif ($null -ne $drift.ValueInDestination -and $null -eq $drift.ValueInSource)
{
$destinationValue = "<table width = '100%'>"
$destinationValue += "<tr><th colspan='2' width='100%' style='border:1px solid black; text-align:middle;background-color:#CCC'>$($drift.CimInstanceKey) = '$($drift.CIMInstanceValue)'</th></tr>"

if ($drift.ValueInDestination.GetType().Name -ne 'OrderedDictionary')
{
$valueForDestination = $drift.ValueInSource
$destinationValue += "<tr><td style='border:1px solid black; text-align:right;'>$($drift.ParameterName)</td><td style='border:1px solid black;'>$valueForDestination</td>"
}
else
{
foreach ($key in $drift.ValueInDestination.Keys)
{
if ($key -ne 'CIMInstance')
{
$valueForDestination = $drift.ValueInDestination.$key
$destinationValue += "<tr><td style='border:1px solid black; text-align:right;'>$key</td><td style='border:1px solid black;'>$valueForDestination</td>"
}
}
}
$destinationValue += "</table>"
}
else
{
$sourceValue += "&nbsp"
$destinationValue += "&nbsp"
}
$parameterName = $Resource.Key
}
Expand Down

0 comments on commit f0c0fc1

Please sign in to comment.