Skip to content

Commit

Permalink
Use correct Graph cmdlets - partial fix for microsoft#3185
Browse files Browse the repository at this point in the history
  • Loading branch information
Borgquite authored Apr 19, 2023
1 parent ab4bef8 commit 72814d5
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 72814d5

Please sign in to comment.