@@ -514,6 +514,19 @@ function Compare-CIPPIntuneObject {
514514 Value = $value
515515 Source = ' Reference'
516516 }
517+ } elseif ($settingInstance.simpleSettingCollectionValue ) {
518+ $label = if ($intuneObj ?.displayName) {
519+ $intuneObj.displayName
520+ } else {
521+ $settingInstance.settingDefinitionId
522+ }
523+ $values = @ ($settingInstance.simpleSettingCollectionValue | ForEach-Object { $_.value })
524+ [PSCustomObject ]@ {
525+ Key = " Simple-$ ( $settingInstance.settingDefinitionId ) "
526+ Label = $label
527+ Value = ($values | Sort-Object ) -join ' , '
528+ Source = ' Reference'
529+ }
517530 } elseif ($settingInstance.choiceSettingValue ?.value) {
518531 $label = if ($intuneObj ?.displayName) {
519532 $intuneObj.displayName
@@ -536,6 +549,30 @@ function Compare-CIPPIntuneObject {
536549 Value = $value
537550 Source = ' Reference'
538551 }
552+
553+ # Recurse into children of choice settings (e.g. firewall profile sub-settings)
554+ if ($settingInstance.choiceSettingValue.children ) {
555+ $childResults = Process - GroupSettingChildren - Children $settingInstance.choiceSettingValue.children - Source ' Reference' - IntuneCollectionIndex $intuneCollectionIndex
556+ foreach ($cr in $childResults ) { $cr }
557+ }
558+ } elseif ($settingInstance.choiceSettingCollectionValue ) {
559+ $label = if ($intuneObj ?.displayName) {
560+ $intuneObj.displayName
561+ } else {
562+ $settingInstance.settingDefinitionId
563+ }
564+ $values = [System.Collections.Generic.List [string ]]::new()
565+ foreach ($choiceValue in $settingInstance.choiceSettingCollectionValue ) {
566+ $option = $intuneObj.options | Where-Object { $_.id -eq $choiceValue.value }
567+ $displayValue = if ($option ?.displayName) { $option.displayName } else { $choiceValue.value }
568+ $values.Add ($displayValue )
569+ }
570+ [PSCustomObject ]@ {
571+ Key = " Choice-$ ( $settingInstance.settingDefinitionId ) "
572+ Label = $label
573+ Value = ($values | Sort-Object ) -join ' , '
574+ Source = ' Reference'
575+ }
539576 } else {
540577 $label = if ($intuneObj ?.displayName) {
541578 $intuneObj.displayName
@@ -586,6 +623,19 @@ function Compare-CIPPIntuneObject {
586623 Value = $value
587624 Source = ' Difference'
588625 }
626+ } elseif ($settingInstance.simpleSettingCollectionValue ) {
627+ $label = if ($intuneObj ?.displayName) {
628+ $intuneObj.displayName
629+ } else {
630+ $settingInstance.settingDefinitionId
631+ }
632+ $values = @ ($settingInstance.simpleSettingCollectionValue | ForEach-Object { $_.value })
633+ [PSCustomObject ]@ {
634+ Key = " Simple-$ ( $settingInstance.settingDefinitionId ) "
635+ Label = $label
636+ Value = ($values | Sort-Object ) -join ' , '
637+ Source = ' Difference'
638+ }
589639 } elseif ($settingInstance.choiceSettingValue ?.value) {
590640 $label = if ($intuneObj ?.displayName) {
591641 $intuneObj.displayName
@@ -608,6 +658,30 @@ function Compare-CIPPIntuneObject {
608658 Value = $value
609659 Source = ' Difference'
610660 }
661+
662+ # Recurse into children of choice settings (e.g. firewall profile sub-settings)
663+ if ($settingInstance.choiceSettingValue.children ) {
664+ $childResults = Process - GroupSettingChildren - Children $settingInstance.choiceSettingValue.children - Source ' Difference' - IntuneCollectionIndex $intuneCollectionIndex
665+ foreach ($cr in $childResults ) { $cr }
666+ }
667+ } elseif ($settingInstance.choiceSettingCollectionValue ) {
668+ $label = if ($intuneObj ?.displayName) {
669+ $intuneObj.displayName
670+ } else {
671+ $settingInstance.settingDefinitionId
672+ }
673+ $values = [System.Collections.Generic.List [string ]]::new()
674+ foreach ($choiceValue in $settingInstance.choiceSettingCollectionValue ) {
675+ $option = $intuneObj.options | Where-Object { $_.id -eq $choiceValue.value }
676+ $displayValue = if ($option ?.displayName) { $option.displayName } else { $choiceValue.value }
677+ $values.Add ($displayValue )
678+ }
679+ [PSCustomObject ]@ {
680+ Key = " Choice-$ ( $settingInstance.settingDefinitionId ) "
681+ Label = $label
682+ Value = ($values | Sort-Object ) -join ' , '
683+ Source = ' Difference'
684+ }
611685 } else {
612686 $label = if ($intuneObj ?.displayName) {
613687 $intuneObj.displayName
@@ -628,11 +702,16 @@ function Compare-CIPPIntuneObject {
628702
629703 $result = [System.Collections.Generic.List [PSObject ]]::new()
630704
631- $allKeys = @ ($referenceItems | Select-Object - ExpandProperty Key) + @ ($differenceItems | Select-Object - ExpandProperty Key) | Sort-Object - Unique
705+ $refItemsByKey = @ {}
706+ foreach ($item in $referenceItems ) { $refItemsByKey [$item.Key ] = $item }
707+ $diffItemsByKey = @ {}
708+ foreach ($item in $differenceItems ) { $diffItemsByKey [$item.Key ] = $item }
709+
710+ $allKeys = @ ($refItemsByKey.Keys ) + @ ($diffItemsByKey.Keys ) | Sort-Object - Unique
632711
633712 foreach ($key in $allKeys ) {
634- $refItem = $referenceItems | Where-Object { $_ .Key -eq $ key } | Select-Object - First 1
635- $diffItem = $differenceItems | Where-Object { $_ .Key -eq $ key } | Select-Object - First 1
713+ $refItem = $refItemsByKey [ $ key]
714+ $diffItem = $diffItemsByKey [ $ key]
636715
637716 $settingId = $key
638717 if ($key -like ' Simple-*' ) {
@@ -654,14 +733,14 @@ function Compare-CIPPIntuneObject {
654733 $diffValue = $diffRawValue
655734
656735 if ($null -ne $settingDefinition -and $null -ne $settingDefinition.options ) {
657- if ($null -ne $refRawValue -and $refRawValue -match ' _\d+$ ' ) {
736+ if ($null -ne $refRawValue -and $refRawValue -is [ string ] ) {
658737 $option = $settingDefinition.options | Where-Object { $_.id -eq $refRawValue }
659738 if ($null -ne $option -and $null -ne $option.displayName ) {
660739 $refValue = $option.displayName
661740 }
662741 }
663742
664- if ($null -ne $diffRawValue -and $diffRawValue -match ' _\d+$ ' ) {
743+ if ($null -ne $diffRawValue -and $diffRawValue -is [ string ] ) {
665744 $option = $settingDefinition.options | Where-Object { $_.id -eq $diffRawValue }
666745 if ($null -ne $option -and $null -ne $option.displayName ) {
667746 $diffValue = $option.displayName
0 commit comments