Remove-AzureRmRoleAssignment cmdlet not working for classic administrators
Hi Team,
We are seeing an issue with Remove-AzureRmRoleAssignment cmdlet, where when we try to remove the administrators who were added from old portal cannot be removed.
Please see below for the trace of the cmdlet and its output.
PS C:\windows\system32> Remove-AzureRmRoleAssignment -SignInName [email protected] -RoleDefinitionName CoAdministrator -Force WARNING: Parameter 'Force' is obsolete. The Force parameter will be removed in a future release. Remove-AzureRmRoleAssignment : The provided information does not map to a role assignment. At line:1 char:1
- Remove-AzureRmRoleAssignment -SignInName [email protected] -Role ...
-
- CategoryInfo : CloseError: (:) [Remove-AzureRmRoleAssignment], KeyNotFoundException - FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.RemoveAzureRoleAssignmentCommand
Besides, when I am trying to fetch the get-azureRmRoleAssignment to check the properties, I am seeing as below (blank for role definition ID,role assignment ID & ObjectID). Not sure, if this is the reason why it's failing.
PS C:\windows\system32> Get-AzureRmRoleAssignment -SignInName [email protected] -IncludeClassicAdministrators
RoleAssignmentId : Scope : /subscriptions/0163afe9-8911-418d-8926-72a61784e3a1 DisplayName : [email protected] SignInName : [email protected] RoleDefinitionName : CoAdministrator RoleDefinitionId : ObjectId : 00000000-0000-0000-0000-000000000000 ObjectType : User
To Remove assignment need to switch to the desired subscription let say I am on subscription A, I can assign role to different resource evening the resource is at subscription B, but I cannot remove an assignment when I am not at the same subscription with the resource, Means I selected on subscription "A" but the resource is at subscription "B", I cannot delete the role assignment which sit on Subscription B. therefore I need to switch my current subscription to B then remove the assignment. otherwise
on your case, you scope is /subscriptions/0163afe9-8911-418d-8926-72a61784e3a1 you need to switch to 0163afe9-8911-418d-8926-72a61784e3a1 subscription, Select-azurermsubscription -subscriptionid 0163afe9-8911-418d-8926-72a61784e3a1
@zteffwong, I followed your steps. Its not removing Co-Admin access. Rest all roles can be removed.
@mrvamsidhar are you talking RBAC or Classic mode. they use two different cmd sets and concept behind are different.
I am having issue w. removing Co Administrator access for a user using Get-AzureRmRoleAssignment. Any help?
@darshanhs90 Can you take a look at this issue?
@mrvamsidhar Could you check if this issue persists with the latest version of powershell.If i remember correctly I had fixed this a month or two back.
Linked to https://github.com/Azure/azure-powershell/issues/5673
I am still running into this. This issue is not resolved. Please reopen this.