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

Use correct Graph cmdlets - fix for #3185 #3186

Merged
merged 3 commits into from
Apr 19, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
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