diff --git a/CHANGELOG.md b/CHANGELOG.md index 26c7c85ccc..bb1487b431 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ * Initial release * IntuneDeviceConfigurationKioskPolicyWindows10 * Initial release +* 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) 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;