azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Remove-AzureRmRoleAssignment cmdlet not working for classic administrators

Open visuram opened this issue 10 years ago • 8 comments

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

visuram avatar Jul 25 '16 23:07 visuram

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 then run your command again.

zteffwong avatar Mar 31 '17 04:03 zteffwong

@zteffwong, I followed your steps. Its not removing Co-Admin access. Rest all roles can be removed.

mrvamsidhar avatar Oct 12 '17 17:10 mrvamsidhar

@mrvamsidhar are you talking RBAC or Classic mode. they use two different cmd sets and concept behind are different.

zteffwong avatar Oct 12 '17 20:10 zteffwong

I am having issue w. removing Co Administrator access for a user using Get-AzureRmRoleAssignment. Any help?

mrvamsidhar avatar Oct 13 '17 20:10 mrvamsidhar

@darshanhs90 Can you take a look at this issue?

maddieclayton avatar Mar 19 '18 20:03 maddieclayton

@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.

darshanhs90 avatar Mar 20 '18 00:03 darshanhs90

Linked to https://github.com/Azure/azure-powershell/issues/5673

darshanhs90 avatar Mar 20 '18 00:03 darshanhs90

I am still running into this. This issue is not resolved. Please reopen this.

ashtewari avatar Aug 09 '18 21:08 ashtewari