Skip to content

Commit

Permalink
Merge pull request #4334 from ricmestre/fix4333
Browse files Browse the repository at this point in the history
M365DSCUtil: Fix #4333
  • Loading branch information
ykuijs authored Feb 26, 2024
2 parents 641c461 + f1e2199 commit b3438f9
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 20 deletions.
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@
* MISC
* M365DSCDRGUtil
Add new parameter for customizable assignment identifier
* M365DSCUtil
Change heuristics on how to find the mandatory key of the resources to
include them as part of the ResourceInstanceName during their export
FIXES [#4333](https://github.com/microsoft/Microsoft365DSC/issues/4333)

# 1.24.221.1

Expand Down Expand Up @@ -85,17 +89,18 @@
* AADConditionalAccessPolicy
* Removed invalid empty string value that was added to the validate set
of two parameters.
* Updated permission reference for app-onlzy authentication.
FIXES [[#3329](https://github.com/microsoft/Microsoft365DSC/issues/3329)]
* Updated permission reference for app-only authentication.
FIXES [#3329](https://github.com/microsoft/Microsoft365DSC/issues/3329)
* AADRoleEligibilityScheduleRequest
* Fixed an issue where an error was thrown if no requests were found instead
of simply returning the Null object.
* AADRoleSetting
* Fix handling of DisplayName property in comparison
FIXES [#4019](https://github.com/microsoft/Microsoft365DSC/issues/4019)
* AADUser
* Fixed and issue where an user would be created even if the resrouce was set to absent.
FIXES [[#4265](https://github.com/microsoft/Microsoft365DSC/issues/4265)]
* Fixed and issue where an user would be created even if the resource was set
to absent.
FIXES [#4265](https://github.com/microsoft/Microsoft365DSC/issues/4265)
* EXOMobileDeviceMailboxPolicy
* Fixes an issue where an empty MinPasswordLength value was always passed down
to the update logic flow.
Expand Down
41 changes: 25 additions & 16 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3361,38 +3361,47 @@ function Get-M365DSCExportContentForResource
$Results = Format-M365DSCString -Properties $Results `
-ResourceName $ResourceName

if ($Script:AllM365DscResources.Count -eq 0)
{
$Script:AllM365DscResources = Get-DscResource -Module 'Microsoft365Dsc'
}

$primaryKey = ''
if ($Results.ContainsKey('IsSingleInstance'))
$Resource = $Script:AllM365DscResources.Where({ $_.Name -eq $ResourceName })
$Keys = $Resource.Properties.Where({ $_.IsMandatory }) | `
Select-Object -ExpandProperty Name
if ($Keys.Contains('IsSingleInstance'))
{
$primaryKey = ''
}
elseif ($Results.ContainsKey('DisplayName'))
elseif ($Keys.Contains('DisplayName'))
{
$primaryKey = $Results.DisplayName
}
elseif ($Results.ContainsKey('Identity'))
{
$primaryKey = $Results.Identity
}
elseif ($Results.ContainsKey('Id'))
{
$primaryKey = $Results.Id
}
elseif ($Results.ContainsKey('Name'))
elseif ($Keys.Contains('Name'))
{
$primaryKey = $Results.Name
}
elseif ($Results.ContainsKey('Title'))
elseif ($Keys.Contains('Title'))
{
$primaryKey = $Results.Title
}
elseif ($Results.ContainsKey('CdnType'))
elseif ($Keys.Contains('Identity'))
{
$primaryKey = $Results.Identity
}
elseif ($Keys.Contains('Id'))
{
$primaryKey = $Results.CdnType
$primaryKey = $Results.Id
}
elseif ($Results.ContainsKey('Usage'))

if ([String]::IsNullOrEmpty($primaryKey) -and `
-not $Keys.Contains('IsSingleInstance'))
{
$primaryKey = $Results.Usage
foreach ($Key in $Keys)
{
$primaryKey += $Results.$Key
}
}

$instanceName = $ResourceName
Expand Down

0 comments on commit b3438f9

Please sign in to comment.