Skip to content

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

Open
@kwill-MSFT

Description

@kwill-MSFT

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;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions