diff --git a/CHANGELOG.md b/CHANGELOG.md index 530acd23a0..ca3a639659 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -63,6 +63,8 @@ * AADRoleEligibilityScheduleRequest * Fixes for Custom roles. FIXES [#5330](https://github.com/microsoft/Microsoft365DSC/issues/5330) + * Fixes to remove elegibility schedule for custom roles. + FIXES [#5331](https://github.com/microsoft/Microsoft365DSC/issues/5331) * AADRoleManagementPolicyRule * Initial release. * AADServicePrincipal diff --git a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 index 964e7f6241..41aa9c982a 100644 --- a/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 +++ b/Modules/Microsoft365DSC/DSCResources/MSFT_AADRoleEligibilityScheduleRequest/MSFT_AADRoleEligibilityScheduleRequest.psm1 @@ -190,7 +190,7 @@ $schedule = $instance } } - [Array]$request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -Filter "PrincipalId eq '$PrincipalId' and RoleDefinitionId eq '$RoleDefinitionId'" | Sort-Object -Property CompletedDateTime -Descending + [Array]$request = Get-MgBetaRoleManagementDirectoryRoleEligibilityScheduleRequest -Filter "PrincipalId eq '$PrincipalId' and RoleDefinitionId eq '$($schedule.RoleDefinitionId)'" | Sort-Object -Property CompletedDateTime -Descending ` if ($request.Length -gt 1) { @@ -200,6 +200,7 @@ } else { + Write-Verbose -Message "Request is not null: $request" $ObjectGuid = [System.Guid]::empty if ($PrincipalType -eq 'User') {