Skip to content

Commit

Permalink
Reimplement fallback for endless loop
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienTschanz committed Sep 17, 2024
1 parent 7cb2783 commit 898f76a
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 4 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
* IntuneDeviceConfigurationSharedMultiDevicePolicyWindows10
* Add missing `AccessTokens` parameter to `Export-TargetResource`
FIXES [#5034](https://github.com/microsoft/Microsoft365DSC/issues/5034)
* IntuneFirewallPolicyWindows10
* Initial release
* M365DSCDRGUtil
* Add support for more complex Intune Settings Catalog properties
* M365DSCResourceGenerator
* Update Intune resource generation for the Settings Catalog.
* SCRoleGroup
* Fixes an issue with creation without specifying Displayname
* Fixes an issue with Drifts because of returned Role format
Expand Down
17 changes: 15 additions & 2 deletions Modules/Microsoft365DSC/Modules/M365DSCDRGUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -2327,6 +2327,7 @@ function Export-IntuneSettingCatalogPolicySettings
else
{
$skip = 0
$breakCounter = 0
$newSettingName = $settingName
do {
$previousSettingName = $newSettingName
Expand All @@ -2342,9 +2343,21 @@ function Export-IntuneSettingCatalogPolicySettings
}
$settingsWithSameName = $combinationMatchesWithOffsetUri
$skip++
} while ($combinationMatchesWithOffsetUri.Count -gt 1)
$breakCounter++
} while ($combinationMatchesWithOffsetUri.Count -gt 1 -and $breakCounter -lt 8)

$settingName = $newSettingName
if ($breakCounter -lt 8)
{
$settingName = $newSettingName
}
else
{
# Alternative way if no unique setting name can be found
$parentSettingIdProperty = $parentSetting.Id.Split('_')[-1]
$parentSettingIdWithoutProperty = $parentSetting.Id.Replace("_$parentSettingIdProperty", "")
# We can't use the entire setting here, because the child setting id does not have to come after the parent setting id
$settingName = $settingDefinition.Id.Replace($parentSettingIdWithoutProperty + "_", "").Replace($parentSettingIdProperty + "_", "")
}
}
}

Expand Down
17 changes: 15 additions & 2 deletions ResourceGenerator/M365DSCResourceGenerator.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3816,6 +3816,7 @@ function New-SettingsCatalogSettingDefinitionSettingsFromTemplate {
else
{
$skip = 0
$breakCounter = 0
$newSettingName = $settingName
do {
$previousSettingName = $newSettingName
Expand All @@ -3831,9 +3832,21 @@ function New-SettingsCatalogSettingDefinitionSettingsFromTemplate {
}
$settingsWithSameName = $combinationMatchesWithOffsetUri
$skip++
} while ($combinationMatchesWithOffsetUri.Count -gt 1)
$breakCounter++
} while ($combinationMatchesWithOffsetUri.Count -gt 1 -and $breakCounter -lt 8)

$settingName = $newSettingName
if ($breakCounter -lt 8)
{
$settingName = $newSettingName
}
else
{
# Alternative way if no unique setting name can be found
$parentSettingIdProperty = $parentSetting.Id.Split('_')[-1]
$parentSettingIdWithoutProperty = $parentSetting.Id.Replace("_$parentSettingIdProperty", "")
# We can't use the entire setting here, because the child setting id does not have to come after the parent setting id
$settingName = $settingDefinition.Id.Replace($parentSettingIdWithoutProperty + "_", "").Replace($parentSettingIdProperty + "_", "")
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
@{
Id = 'device_vendor_msft_defender_configuration_devicecontrol_policyrules_{ruleid}_ruledata_id'
Name = 'Id'
OffsetUri = '/configuration/devicecontrol/policyrules/{0}/ruledata'
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.deviceManagementConfigurationSimpleSettingDefinition'
dependentOn = @(
Expand Down Expand Up @@ -353,6 +354,7 @@ Describe -Name $Global:DscHelper.DescribeHeader -Fixture {
@{
Id = 'device_vendor_msft_defender_configuration_devicecontrol_policyrules_{ruleid}_ruledata_entry_id'
Name = 'Id'
OffsetUri = '/configuration/devicecontrol/policyrules/{0}/ruledata'
AdditionalProperties = @{
'@odata.type' = '#microsoft.graph.deviceManagementConfigurationSimpleSettingDefinition'
dependentOn = @(
Expand Down

0 comments on commit 898f76a

Please sign in to comment.