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