diff --git a/CHANGELOG.md b/CHANGELOG.md index 38834df6c1..26c7c85ccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,17 +8,18 @@ * Initial release * IntuneDeviceConfigurationKioskPolicyWindows10 * Initial release +* SCLabelPolicy + * If label policy is set to None don't get its label display name since it's not required + FIXES [#3104](https://github.com/microsoft/Microsoft365DSC/issues/3104) * DRG * Fixed issue retrieving the cmdlet definition when the resource type is derived from an abstract type * Fixed issue with UnitTest and complex properties with AdditionalProperties * Fixed issue with Complex constructor and complex properties with AdditionalProperties -* SCLabelPolicy - * If label policy is set to None don't get its label display name since it's not required - FIXES [#3104](https://github.com/microsoft/Microsoft365DSC/issues/3104) * MISC * Reports will now exclude the authentication parameters (e.g., CertificateThumbprint, Credential, etc.). * Changed the Encoding helper's logic to ensure titled quotes and apostrophes are correctly evaluated. FIXES [#3165](https://github.com/microsoft/Microsoft365DSC/issues/3165) + * Fixes an issue where the new resource name extraction could still have duplicates. # 1.23.412.1 diff --git a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 index fc9fed50ab..cd5ac7d57c 100644 --- a/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 +++ b/Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1 @@ -1128,6 +1128,9 @@ function Export-M365DSCConfiguration $ManagedIdentity ) + # Define the exported resource instances' names Global variable + $Global:M365DSCExportedResourceInstancesNames = @() + # LaunchWebUI specified, launching that now if ($LaunchWebUI) { @@ -1308,6 +1311,9 @@ function Export-M365DSCConfiguration -AllComponents ` -Filters $Filters } + + # Clear the exported resource instances' names Global variable + $Global:M365DSCExportedResourceInstancesNames = $null } $Script:M365DSCDependenciesValidated = $false @@ -3230,6 +3236,19 @@ function Get-M365DSCExportContentForResource { $instanceName += "-$($Results.Workload)" } + + # Check to see if a resource with this exact name was already exported, if so, append a number to the end. + $i = 2 + $tempName = $instanceName + while ($null -ne $Global:M365DSCExportedResourceInstancesNames -and ` + $Global:M365DSCExportedResourceInstancesNames.Contains($tempName)) + { + $tempName = $instanceName + "-" + $i.ToString() + $i++ + } + $instanceName = $tempName + $Global:M365DSCExportedResourceInstancesNames += $tempName + $content = " $ResourceName `"$instanceName`"`r`n" $content += " {`r`n" $partialContent = Get-DSCBlock -Params $Results -ModulePath $ModulePath @@ -3286,6 +3305,7 @@ function Get-M365DSCExportContentForResource } $content += $partialContent $content += " }`r`n" + return $content }