Remove-AzRoleAssignment : Multiple role definitions found with name ''

Open Beginner friendly
#15,346 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
62/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
azure, csharp, powershell

Research direction

Start in RemoveAzureRoleAssignmentCommand.cs at the InputObject parameter-bound block and reproduce the failure with multiple role assignments whose RoleDefinitionName is empty. Trace how the input object's role definition identifier is handled there, then verify that piping the assignment to Remove-AzRoleAssignment succeeds without the ambiguous-name error.

Written by the indexing model from the issue text.

Description

act-identity-squad ARM - RBAC Service Attention

Description

If a scope has multiple role assignments with an empty RoleDefinitionName, then Remove-AzRoleAssignment will fail with the following error:

PS C:\Users\kwill> $DeprecatedAccounts[0] | Remove-AzRoleAssignment
Remove-AzRoleAssignment : Multiple role definitions found with name ''. Specify role definition using it's Id instead.
At line:1 char:26

$DeprecatedAccounts[0] | Remove-AzRoleAssignment
~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : CloseError: (:) [Remove-AzRoleAssignment], InvalidOperationException
FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.RemoveAzureRoleAssignmentCommand

To fix, RemoveAzureRoleAssignmentCommand.cs should include the roleDefinitionId in this section of code:
if (this.IsParameterBound(c => c.InputObject))
{
Scope = InputObject.Scope;
ObjectId = InputObject.ObjectId;
RoleDefinitionName = InputObject.RoleDefinitionName;
}

Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 21h
Merged PRs (30d)
49

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from Azure/azure-powershell

All issues in Azure/azure-powershell

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.