Skip to content

Commit

Permalink
Merge pull request #3190 from Borgquite/patch-2
Browse files Browse the repository at this point in the history
Fix AADAdministrativeUnit ScopedRoleMembers of Group or ServicePrincipal type - fixes #3189
  • Loading branch information
ykuijs authored Apr 20, 2023
2 parents 3aecdd9 + ceb3a63 commit c3d44d3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Change log for Microsoft365DSC

# UNRELEASED

* AADAdministrativeUnit
* Fix issue creating ScopedRoleMembers of Type Group or ServicePrincipal
FIXES [#3189](https://github.com/microsoft/Microsoft365DSC/issues/3189)

# 1.23.419.1

* IntuneDeviceConfigurationDefenderForEndpointOnboardingPolicyWindows10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ function Set-TargetResource
$scopedRoleMemberSpecification = @()
foreach ($roleMember in $CreateParameters.ScopedRoleMembers)
{
Write-Verbose -Message "AU {$DisplayName} member: role '$($roleMember.RoleName)' type '$($roleMember.Type)' identity $($roleMember.Identity)"
Write-Verbose -Message "AU {$DisplayName} member: role '$($roleMember.RoleName)' type '$($roleMember.RoleMemberInfo.Type)' identity $($roleMember.RoleMemberInfo.Identity)"
try
{
$roleObject = Get-MgDirectoryRole -Filter "DisplayName eq '$($roleMember.RoleName)'" -ErrorAction stop
Expand Down Expand Up @@ -462,15 +462,15 @@ function Set-TargetResource
throw "AU {$($DisplayName)}: Scoped Role User {$($roleMember.RoleMemberInfo.Identity)} for role {$($roleMember.RoleName)} does not exist"
}
}
elseif ($roleMember.Type -eq 'Group')
elseif ($roleMember.RoleMemberInfo.Type -eq 'Group')
{
$roleMemberIdentity = Get-MgGroup -Filter "displayName eq '$($roleMember.RoleMemberInfo.Identity)'" -ErrorAction Stop
if ($null -eq $roleMemberIdentity)
{
throw "AU {$($DisplayName)}: Scoped Role Group {$($roleMember.RoleMemberInfo.Identity)} for role {$($roleMember.RoleName)} does not exist"
}
}
elseif ($roleMember.Type -eq 'ServicePrincipal')
elseif ($roleMember.RoleMemberInfo.Type -eq 'ServicePrincipal')
{
$roleMemberIdentity = Get-MgServicePrincipal -Filter "displayName eq '$($roleMember.RoleMemberInfo.Identity)'" -ErrorAction Stop
if ($null -eq $roleMemberIdentity)
Expand Down

0 comments on commit c3d44d3

Please sign in to comment.