Skip to content

Commit 17df435

Browse files
authored
Merge pull request #88142 from WhitWaldo/patch-10
Added PS for removing orphaned role assignments
2 parents 9b1ce13 + 54ac2df commit 17df435

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

articles/active-directory/managed-identities-azure-resources/managed-identity-best-practice-recommendations.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ will be displayed with “Identity not found” when viewed in the portal. [Read
106106

107107
:::image type="content" source="media/managed-identity-best-practice-recommendations/identity-not-found.png" alt-text="Identity not found for role assignment.":::
108108

109+
Role assignments which are no longer associated with a user or service principal will appear with an `ObjectType` value of `Unknown`. In order to remove them, you can pipe several Azure PowerShell commands together to first get all the role assignments, filter to only those with an `ObjectType` value of `Unknown` and then remove those role assignments from Azure.
110+
111+
```azurepowershell
112+
Get-AzRoleAssignment | Where-Object {$_.ObjectType -eq "Unknown"} | Remove-AzRoleAssignment
113+
```
114+
109115
## Limitation of using managed identities for authorization
110116

111117
Using Azure AD **groups** for granting access to services is a great way to simplify the authorization process. The idea is simple – grant permissions to a group and add identities to the group so that they inherit the same permissions. This is a well-established pattern from various on-premises systems and works well when the identities represent users. Another option to control authorization in Azure AD is by using [App Roles](../develop/howto-add-app-roles-in-azure-ad-apps.md), which allows you to declare **roles** that are specific to an app (rather than groups, which are a global concept in the directory). You can then [assign app roles to managed identities](how-to-assign-app-role-managed-identity-powershell.md) (as well as users or groups).

0 commit comments

Comments
 (0)