Skip to content

Commit

Permalink
Merge pull request #3306 from NikCharlebois/Fix-#3226
Browse files Browse the repository at this point in the history
Fixes #3226
  • Loading branch information
NikCharlebois authored May 15, 2023
2 parents c968d27 + 70e86b4 commit b4ca8a7
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
* IntuneSettingCatalogCustomPolicyWindows10
* Add missing properties to schema
FIXES [#3300](https://github.com/microsoft/Microsoft365DSC/issues/3300)
* SPOUserProfileProperty
* Fixes and issue where the properties weren't properly set.
FIXES [#3226](https://github.com/microsoft/Microsoft365DSC/issues/3226)
* MISC
* Major performance improvements for the New-M365DSCDeltaReport cmdlet.
FIXES [#3016](https://github.com/microsoft/Microsoft365DSC/issues/3016)
Expand Down
42 changes: 31 additions & 11 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,7 @@ function Compare-PSCustomObjectArrays
[System.Object[]]
$CurrentValues
)

$VerbosePreference = 'Continue'
$DriftedProperties = @()
foreach ($DesiredEntry in $DesiredValues)
{
Expand All @@ -466,15 +466,27 @@ function Compare-PSCustomObjectArrays
{
$propertyName = $property.Name

if ($DesiredEntry.$PropertyName -ne $EquivalentEntryInCurrent.$PropertyName)
if ((-not [System.String]::IsNullOrEmpty($DesiredEntry.$PropertyName) -and -not [System.String]::IsNullOrEmpty($EquivalentEntryInCurrent.$PropertyName)) -and `
$DesiredEntry.$PropertyName -ne $EquivalentEntryInCurrent.$PropertyName)
{
$result = @{
Property = $DesiredEntry
PropertyName = $PropertyName
Desired = $DesiredEntry.$PropertyName
Current = $EquivalentEntryInCurrent.$PropertyName
$drift = $true
if ($DesiredEntry.$PropertyName.Contains('$OrganizationName'))
{
if ($DesiredEntry.$PropertyName.Split('@')[0] -eq $EquivalentEntryInCurrent.$PropertyName.Split('@')[0])
{
$drift = $false
}
}
if ($drift)
{
$result = @{
Property = $DesiredEntry
PropertyName = $PropertyName
Desired = $DesiredEntry.$PropertyName
Current = $EquivalentEntryInCurrent.$PropertyName
}
$DriftedProperties += $result
}
$DriftedProperties += $result
}
}
}
Expand Down Expand Up @@ -553,7 +565,7 @@ function Test-M365DSCParameterState
[System.String]
$Tenant
)

$verbosePreference = 'Continue'
#region Telemetry
$data = [System.Collections.Generic.Dictionary[[String], [String]]]::new()
$data.Add('Resource', "$Source")
Expand Down Expand Up @@ -638,20 +650,28 @@ function Test-M365DSCParameterState
{
$value = $null
}
$currentEntry.Add($prop.Name, $value)
if (-not $currentEntry.ContainsKey($prop.Name))
{
$currentEntry.Add($prop.Name, $value)
}
}
$AllDesiredValuesAsArray += [PSCustomObject]$currentEntry
}

$arrayCompare = Compare-PSCustomObjectArrays -CurrentValues $CurrentValues.$fieldName `
-DesiredValues $AllDesiredValuesAsArray

if ($null -ne $arrayCompare)
{
foreach ($item in $arrayCompare)
{
$EventValue = "<CurrentValue>[$($item.PropertyName)]$($item.CurrentValue)</CurrentValue>"
$EventValue += "<DesiredValue>[$($item.PropertyName)]$($item.DesiredValue)</DesiredValue>"
$DriftedParameters.Add($fieldName, $EventValue)

if (-not $DriftedParameters.ContainsKey($fieldName))
{
$DriftedParameters.Add($fieldName, $EventValue)
}
}
$returnValue = $false
}
Expand Down

0 comments on commit b4ca8a7

Please sign in to comment.