I want to remove an EntraID (AzureAD) role for a user, me.
I try to use Remove-MgRoleManagementDirectoryRoleEligibilitySchedule command.
I get the UnifiedRoleEligibilityScheduleId with :
$SearchId = Get-MgRoleManagementDirectoryRoleEligibilitySchedule -Filter "PrincipalId eq '$($me.Id)'"
I can verify me ID with :
Get-MgRoleManagementDirectoryRoleEligibilitySchedule -UnifiedRoleEligibilityScheduleId $SearchId.Id
But when I use
Remove-MgRoleManagementDirectoryRoleEligibilitySchedule -UnifiedRoleEligibilityScheduleId $SearchId.Id
I have this error :
DEBUG
DEBUG: [Authentication]: - Scopes: [...,RoleManagement.ReadWrite.Directory,...]
...
HTTP Method:
DELETE
Absolute Uri:
https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules/$SearchId.Id
...
"message": "{"message":"No HTTP resource was found that matches the request URI 'https://api.azrbac.mspim.azure.com/api/v3/roleManagement/directory/roleEligibilitySchedules('$SearchId.Id')?'."}"
Is the command Remove-MgRoleManagementDirectoryRoleEligibilitySchedule really functionnal ?
Thanks !
2
Answers
Aaaaaaaaaah I didn't check this part of the doc ! New-something to remove something, it is not intuitive :)
Thanks a lot Sridevi !
I have one Entra ID (Azure AD) eligibility role "Application Administrator" assigned to me:
When I ran the same commands to remove the above eligibility assignment, I too got same error like this:
Response:
Note that, Microsoft Graph PowerShell SDK calls MS Graph API queries in the backend while executing the code. You can confirm that by adding
-Debug
at the end of command like this:Response:
Alternatively, make use of below PowerShell script to remove the eligibility role like this:
Response:
When I checked the same in Portal, eligibility role removed successfully as below:
Reference:
Create roleEligibilityScheduleRequest – Microsoft Graph