Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.21k stars 3.82k forks source link

[Feature]: Remove-AzRoleAssignment : Remove classical Administrator #21110

Open Thomas-Mou opened 1 year ago

Thomas-Mou commented 1 year ago

Description of the new feature

Description

When using the command "Remove-AzRoleAssignment" unable to delete "Classical Administrator"

PS > $role = Get-AzRoleAssignment -IncludeClassicAdministrators | Where-Object {$_.RoleDefinitionName -like "*ServiceAdministrator*"}
PS > Remove-AzRoleAssignment -SignInName $role.SignInName -RoleDefinitionName "ServiceAdministrator" -Scope $role.Scope

Error output

Remove-AzRoleAssignment : The provided information does not map to a role assignment.
Au caractère Ligne:1 : 1
+ Remove-AzRoleAssignment -SignInName $role.SignInName -RoleDefinitionN ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError : (:) [Remove-AzRoleAssignment], KeyNotFoundException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Resources.RemoveAzureRoleAssignmentCommand

Proposed implementation details (optional)

Like the cmdlet Get-AzRoleAssignment include a parameter -IncludeClassicAdministrators to be able to delete Classical Admin

Get-AzRoleAssignment -IncludeClassicAdministrators

Remove-AzRoleAssignment -SignInName $SignInName -RoleDefinitionName "ServiceAdministrator" -Scope $Scope -IncludeClassicAdministrators
isra-fel commented 1 year ago

Thanks for the feedback Thomas! Azure PowerShell team will investigate and discuss it :)

epiHATR commented 4 months ago

same issues when tried to remove Classic Administrator.