Skip to content

Commit

Permalink
Merge pull request #5545 from NikCharlebois/Fix-#5532
Browse files Browse the repository at this point in the history
Fix #5532
  • Loading branch information
NikCharlebois authored Dec 12, 2024
2 parents 0983c9c + e3746a3 commit fde3c01
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
* AADFeatureRolloutPolicy
* Fixed policy retrieval
FIXES [#5521](https://github.com/microsoft/Microsoft365DSC/issues/5521)
* AADRoleEligibilityScheduleRequest
* Changed logic to retrieve instance by Service Principal with custom role.
FIXES [#5532](https://github.com/microsoft/Microsoft365DSC/issues/5532)
* IntuneDeviceManagementAndroidDeviceOwnerEnrollmentProfile
* Fixing issue with the way the QrCodeImage property was exported and handled.
* IntuneFirewallPolicyWindows10
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,10 +148,24 @@ function Get-TargetResource
[Array] $requests = Get-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -Filter "PrincipalId eq '$($PrincipalInstance.Id)' and RoleDefinitionId eq '$($RoleDefinitionId)' and DirectoryScopeId eq '$($DirectoryScopeId)'"
if ($requests.Length -eq 0)
{
return $nullResult
Write-Verbose -Message "Trying to retrieve by reverse RoleId retrieval"
$partialRequests = Get-MgBetaRoleManagementDirectoryRoleAssignmentScheduleRequest -Filter "PrincipalId eq '$($PrincipalInstance.Id)' and DirectoryScopeId eq '$($DirectoryScopeId)'"
$reverseRoleId = $null
foreach ($partialRequest in $partialRequests)
{
$roleEntry = Get-MgBetaRoleManagementDirectoryRoleDefinition -UnifiedRoleDefinitionId $partialRequest.RoleDefinitionId | Where-Object -FilterScript {$_.DisplayName -eq $RoleDefinition}
if ($null -ne $roleEntry)
{
$request = $partialRequest
$RoleDefinitionId = $partialRequest.RoleDefinitionId
break
}
}
}
else
{
$request = $requests[0]
}

$request = $requests[0]
}

$schedules = Get-MgBetaRoleManagementDirectoryRoleAssignmentSchedule -Filter "PrincipalId eq '$($request.PrincipalId)'"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
$PrincipalValue = $PrincipalInstance.DisplayName
}

Write-Verbose -Message 'Found Principal'
Write-Verbose -Message "Found Principal {$PrincipalValue}"
$RoleDefinitionId = (Get-MgBetaRoleManagementDirectoryRoleDefinition -Filter "DisplayName eq '$RoleDefinition'").Id
Write-Verbose -Message "Retrieved role definition {$RoleDefinition} with ID {$RoleDefinitionId}"

Expand Down

0 comments on commit fde3c01

Please sign in to comment.