Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

M365DSCUtil: Fix #4333 #4334

Merged
merged 15 commits into from
Feb 26, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
* MISC
* Uninstall-M365DSCOutdatedDependencies
* Outdated Microsoft365DSC-modules are now removed in their entirety
* 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.214.3

Expand Down Expand Up @@ -51,17 +55,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
40 changes: 24 additions & 16 deletions Modules/Microsoft365DSC/Modules/M365DSCUtil.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -3361,38 +3361,46 @@ function Get-M365DSCExportContentForResource
$Results = Format-M365DSCString -Properties $Results `
-ResourceName $ResourceName

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

$primaryKey = ''
andikrueger marked this conversation as resolved.
Show resolved Hide resolved
if ($Results.ContainsKey('IsSingleInstance'))
$Resource = $Script:AllM365DscResources.Where({ $_.Name -eq $ResourceName })
$Keys = $Resource.Properties.Where({ $_.IsMandatory }) | `
andikrueger marked this conversation as resolved.
Show resolved Hide resolved
Select-Object -ExpandProperty Name
if ($Keys.Contains('IsSingleInstance'))
{
$primaryKey = ''
andikrueger marked this conversation as resolved.
Show resolved Hide resolved
}
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))
{
$primaryKey = $Results.Usage
foreach ($Key in $Keys)
{
$primaryKey += $Results.$Key
}
}

$instanceName = $ResourceName
Expand Down
Loading