Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2873 #2955

Merged
merged 2 commits into from
Mar 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log for Microsoft365DSC

# UNRELEASED

* MISC
* Updated logic for drift detection to be case insensitive.
FIXES [#2873](https://github.com/microsoft/Microsoft365DSC/issues/2873)

# 1.23.301.1

* IntuneDeviceEnrollmentConfigurationWindows10
Expand Down
40 changes: 27 additions & 13 deletions Modules/Microsoft365DSC/Modules/M365DSCReport.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -548,10 +548,17 @@ function Compare-M365DSCConfigurations
{
if ($propertyName -notin $filteredProperties)
{
$destinationPropertyName = $destinationResource.Keys | Where-Object -FilterScript {$_ -eq $propertyName}
if ([System.String]::IsNullOrEmpty($destinationPropertyName))
{
$destinationPropertyName = $propertyName
}

# Needs to be a separate nested if statement otherwise the ReferenceObject an be null and it will error out;
if ($destinationResource.ContainsKey($propertyName) -eq $false -or (-not [System.String]::IsNullOrEmpty($propertyName) -and
$null -ne (Compare-Object -ReferenceObject ($sourceResource.$propertyName)`
-DifferenceObject ($destinationResource.$propertyName))))
if ($destinationResource.ContainsKey($destinationPropertyName) -eq $false -or (-not [System.String]::IsNullOrEmpty($propertyName) -and
$null -ne (Compare-Object -ReferenceObject ($sourceResource.$propertyName)`
-DifferenceObject ($destinationResource.$destinationPropertyName))) -and
-not ([System.String]::IsNullOrEmpty($destinationResource.$destinationPropertyName) -and [System.String]::IsNullOrEmpty($sourceResource.$propertyName)))
{
if ($null -eq $drift)
{
Expand All @@ -562,13 +569,13 @@ function Compare-M365DSCConfigurations
Properties = @(@{
ParameterName = $propertyName
ValueInSource = $sourceResource.$propertyName
ValueInDestination = $destinationResource.$propertyName
ValueInDestination = $destinationResource.$destinationPropertyName
})
}

if ($destinationResource.Contains("_metadata_$($propertyName)"))
if ($destinationResource.Contains("_metadata_$($destinationPropertyName)"))
{
$Metadata = $destinationResource."_metadata_$($propertyName)"
$Metadata = $destinationResource."_metadata_$($destinationPropertyName)"
$Level = $Metadata.Split('|')[0].Replace('### ', '')
$Information = $Metadata.Split('|')[1]
$drift.Properties[0].Add('_Metadata_Level', $Level)
Expand All @@ -580,11 +587,11 @@ function Compare-M365DSCConfigurations
$newDrift = @{
ParameterName = $propertyName
ValueInSource = $sourceResource.$propertyName
ValueInDestination = $destinationResource.$propertyName
ValueInDestination = $destinationResource.$destinationPropertyName
}
if ($destinationResource.Contains("_metadata_$($propertyName)"))
if ($destinationResource.Contains("_metadata_$($destinationPropertyName)"))
{
$Metadata = $destinationResource."_metadata_$($propertyName)"
$Metadata = $destinationResource."_metadata_$($destinationPropertyName)"
$Level = $Metadata.Split('|')[0].Replace('### ', '')
$Information = $Metadata.Split('|')[1]
$newDrift.Add('_Metadata_Level', $Level)
Expand All @@ -602,8 +609,13 @@ function Compare-M365DSCConfigurations
{
if ($propertyName -notin $filteredProperties)
{
$sourcePropertyName = $destinationResource.Keys | Where-Object -FilterScript {$_ -eq $propertyName}
if ([System.String]::IsNullOrEmpty($sourcePropertyName))
{
$sourcePropertyName = $propertyName
}
if (-not [System.String]::IsNullOrEmpty($propertyName) -and
-not $sourceResource.Contains($propertyName))
-not $sourceResource.Contains($sourcePropertyName))
{
if ($null -eq $drift)
{
Expand All @@ -612,7 +624,7 @@ function Compare-M365DSCConfigurations
Key = $keyName
KeyValue = $SourceKeyValue
Properties = @(@{
ParameterName = $propertyName
ParameterName = $sourcePropertyName
ValueInSource = $null
ValueInDestination = $destinationResource.$propertyName
})
Expand All @@ -621,7 +633,7 @@ function Compare-M365DSCConfigurations
else
{
$drift.Properties += @{
ParameterName = $propertyName
ParameterName = $sourcePropertyName
ValueInSource = $null
ValueInDestination = $destinationResource.$propertyName
}
Expand Down Expand Up @@ -1128,7 +1140,9 @@ function New-M365DSCDeltaReport
$cellStyle = "vertical-align:top;"
}

if ($destinationValue.GetType().Name -eq 'Object[]' -and -not [System.String]::IsNullOrEmpty($CIMType))
if (-not [System.String]::IsNullOrEmpty($destinationValue) -and
$destinationValue.GetType().Name -eq 'Object[]' -and
-not [System.String]::IsNullOrEmpty($CIMType))
{
$destinationValue = ""
$orderedKeys = $drift.ValueInDestination.Key | Sort-Object
Expand Down