From 72814d595b0a172fbab9903100f3153ce4c3effc Mon Sep 17 00:00:00 2001 From: Chris Hill <53898223+Borgquite@users.noreply.github.com> Date: Wed, 19 Apr 2023 16:13:35 +0100 Subject: [PATCH 1/2] Use correct Graph cmdlets - partial fix for #3185 --- .../MSFT_EXOManagementRoleAssignment.psm1 | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 index c11267c968..261c43d6fe 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_EXOManagementRoleAssignment/MSFT_EXOManagementRoleAssignment.psm1 @@ -131,7 +131,7 @@ function Get-TargetResource { $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` -InboundParameters $PSBoundParameters - $adminUnit = Get-MgAdministrativeUnit -AdministrativeUnitId $roleAssignment.CustomRecipientWriteScope + $adminUnit = Get-MgDirectoryAdministrativeUnit -AdministrativeUnitId $roleAssignment.CustomRecipientWriteScope if ($RecipientAdministrativeUnitScope -eq $adminUnit.Id) { @@ -315,12 +315,14 @@ function Set-TargetResource if (-not [System.String]::IsNullOrEmpty($RecipientAdministrativeUnitScope)) { $NewManagementRoleParams.Remove('CustomRecipientWriteScope') | Out-Null - $adminUnit = Get-AdministrativeUnit -Identity $RecipientAdministrativeUnitScope -ErrorAction SilentlyContinue + $ConnectionMode = New-M365DSCConnection -Workload 'MicrosoftGraph' ` + -InboundParameters $PSBoundParameters + $adminUnit = Get-MgDirectoryAdministrativeUnit -AdministrativeUnitId $RecipientAdministrativeUnitScope -ErrorAction SilentlyContinue if ($null -eq $adminUnit) { - $adminUnit = Get-AdministrativeUnit | Where-Object -FilterScript { $_.DisplayName -eq $RecipientAdministrativeUnitScope } + $adminUnit = Get-MgDirectoryAdministrativeUnit -All | Where-Object -FilterScript { $_.DisplayName -eq $RecipientAdministrativeUnitScope } } - $NewManagementRoleParams.RecipientAdministrativeUnitScope = $adminUnit.Name + $NewManagementRoleParams.RecipientAdministrativeUnitScope = $adminUnit.Id } # CASE: Management Role doesn't exist but should; From df4bdbbc35dd498e774878ddd63ae3b7d39f741d Mon Sep 17 00:00:00 2001 From: Chris Hill <53898223+Borgquite@users.noreply.github.com> Date: Wed, 19 Apr 2023 17:17:49 +0100 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 38834df6c1..f658be3367 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,9 @@ * 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 +* EXOManagementRoleAssignment + * Fixed issue with incorrect Microsoft Graph cmdlets used to retrieve Administrative Units. + FIXES [#3185](https://github.com/microsoft/Microsoft365DSC/issues/3185) * 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)