@@ -44,11 +44,16 @@ function Compare-CIPPIntuneObject {
4444
4545 function Compare-ObjectsRecursively {
4646 param (
47- [Parameter (Mandatory = $true )] $Object1 ,
48- [Parameter (Mandatory = $true )] $Object2 ,
49- [Parameter (Mandatory = $false )] [string ]$PropertyPath = ' ' ,
47+ [Parameter (Mandatory = $true )]
48+ $Object1 ,
49+
50+ [Parameter (Mandatory = $true )]
51+ $Object2 ,
52+
53+ [Parameter (Mandatory = $false )]
54+ [string ]$PropertyPath = ' ' ,
5055 [int ]$Depth = 0 ,
51- [int ]$MaxDepth = 15
56+ [int ]$MaxDepth = 20
5257 )
5358
5459 if ($Depth -ge $MaxDepth ) {
@@ -82,6 +87,21 @@ function Compare-CIPPIntuneObject {
8287 return
8388 }
8489
90+ # Short-circuit recursion for primitive types
91+ $primitiveTypes = @ ([double ], [decimal ], [datetime ], [timespan ], [guid ] )
92+ foreach ($type in $primitiveTypes ) {
93+ if ($Object1 -is $type -and $Object2 -is $type ) {
94+ if ($Object1 -ne $Object2 ) {
95+ $result.Add ([PSCustomObject ]@ {
96+ Property = $PropertyPath
97+ ExpectedValue = $Object1
98+ ReceivedValue = $Object2
99+ })
100+ }
101+ return
102+ }
103+ }
104+
85105 if ($Object1 -is [System.Collections.IDictionary ]) {
86106 $allKeys = @ ($Object1.Keys ) + @ ($Object2.Keys ) | Select-Object - Unique
87107
@@ -197,6 +217,7 @@ function Compare-CIPPIntuneObject {
197217 } else {
198218 $intuneCollection = Get-Content .\intuneCollection.json | ConvertFrom-Json - ErrorAction SilentlyContinue
199219
220+ # Process reference object settings
200221 $referenceItems = $ReferenceObject.settings | ForEach-Object {
201222 $settingInstance = $_.settingInstance
202223 $intuneObj = $intuneCollection | Where-Object { $_.id -eq $settingInstance.settingDefinitionId }
@@ -223,6 +244,8 @@ function Compare-CIPPIntuneObject {
223244 $child.choiceSettingValue.value
224245 }
225246 }
247+
248+ # Add object to our temporary list
226249 [PSCustomObject ]@ {
227250 Key = " GroupChild-$ ( $child.settingDefinitionId ) "
228251 Label = $childLabel
@@ -288,6 +311,7 @@ function Compare-CIPPIntuneObject {
288311 $tempOutput
289312 }
290313
314+ # Process difference object settings
291315 $differenceItems = $DifferenceObject.settings | ForEach-Object {
292316 $settingInstance = $_.settingInstance
293317 $intuneObj = $intuneCollection | Where-Object { $_.id -eq $settingInstance.settingDefinitionId }
@@ -314,6 +338,8 @@ function Compare-CIPPIntuneObject {
314338 $child.choiceSettingValue.value
315339 }
316340 }
341+
342+ # Add object to our temporary list
317343 [PSCustomObject ]@ {
318344 Key = " GroupChild-$ ( $child.settingDefinitionId ) "
319345 Label = $childLabel
0 commit comments