To find role assignments of deleted identities in Azure, list each subscription's role assignments and keep those whose ObjectType is Unknown. Azure doesn't remove an assignment when its user, group or app is deleted. An account that can't read the directory sees every principal as Unknown, so run the check with one that can.
| Method | Best fit |
|---|---|
| PowerShell | A CSV of leftover assignments across your enabled subscriptions. |
| Admin centre | A quick look at 1 scope's assignments for Identity not found. |
| Altivane | Recommended for regular clean-ups, with deleted identities told apart from names that couldn't be read. |
Before you start
Use an account that can read role assignments at the scopes you want to check, such as one with the built-in Reader role, and that can read the directory. A member account of the tenant can by default; a guest account has restricted directory permissions, so every principal looks unknown to it. Microsoft lists no separate licence for reading assignments.
Know why the rows matter. Microsoft says an assignment to a deleted principal still grants access while that principal holds a valid token that hasn't expired, and the assignments count towards each subscription's limit. A user invited moments ago can also show as not found until it replicates, so check new names again before acting. The examples read and export, and change nothing. The script's finally block disconnects the account and clears its saved Azure contexts.
Option 1
Find role assignments of deleted identities with PowerShell
Install the modules once. The script reads the assignments of each enabled subscription, stops if no principal could be named, and saves the assignments whose principal is unknown.
Install-Module -Name Az.Accounts, Az.Resources -Repository PSGallery -Scope CurrentUser$ErrorActionPreference = 'Stop'
Connect-AzAccount -ErrorAction Stop
try {
$subscriptions = @(Get-AzSubscription | Where-Object State -eq 'Enabled')
if ($subscriptions.Count -eq 0) {
Write-Output 'No enabled subscriptions are available to this account.'
return
}
$all = @{}
foreach ($sub in $subscriptions) {
Set-AzContext -Subscription $sub.Id -Tenant $sub.TenantId -Scope Process | Out-Null
Get-AzRoleAssignment | ForEach-Object { $all[$_.RoleAssignmentId] = $_ }
}
$known = @($all.Values | Where-Object ObjectType -ne 'Unknown')
if ($all.Count -gt 0 -and $known.Count -eq 0) {
Write-Output 'Every principal is Unknown. Check that this account can read the directory.'
return
}
$rows = @($all.Values | Where-Object ObjectType -eq 'Unknown' |
Sort-Object Scope, RoleDefinitionName)
if ($rows.Count -eq 0) {
Write-Output 'No role assignments to deleted identities were found.'
} else {
$rows | Select-Object ObjectId, RoleDefinitionName, Scope, RoleAssignmentId |
Export-Csv -Path './deleted-identity-assignments.csv' -NoTypeInformation -Encoding utf8
Write-Output "$($rows.Count) assignments saved to deleted-identity-assignments.csv."
}
} finally {
Disconnect-AzAccount | Out-Null
}The CSV holds the object ID the assignment names, the role, the scope and the assignment ID, which is what you need to remove it later. An assignment at a management group or the root is read from every subscription it reaches, so the script keeps each assignment ID once. To check fewer subscriptions, filter $subscriptions. Before removing a row, search the directory for its object ID: if it belongs to an object that still exists, the account couldn't read it rather than it being deleted.
Option 2
Find deleted identities in the Azure portal
- Sign in to the Azure portal with an account that can read the scope's role assignments and the directory.
- Choose All services > Subscriptions, or Management groups, then select the scope.
- Choose Access control (IAM) > Role assignments.
- Look for principals listed as Identity not found with the type Unknown, and note each one's role and scope.
- Repeat for each subscription and management group. Leave the page without removing anything.
Download role assignments leaves these assignments out of its file, so the list on screen is the portal's only view of them. This method suits a quick look at 1 scope; for every subscription at once, use PowerShell or Altivane.
Option 3 ยท Recommended for regular clean-ups
Find deleted identities with Altivane
- Open Altivane and choose the tenant.
- Run the Azure Access to Review report.
- Open the Excel workbook and find Assignments to deleted identities: each assignment whose user, group or app Microsoft Graph no longer knows, with its role, scope, subscription and assignment ID.
- Build the tenant's documents with the Azure Access scorecard report to count them in the Word report as assignments to identities that no longer exist.
The report covers every subscription where you gave Altivane the Reader role, and lists an assignment read from several subscriptions once. A deleted identity is told apart from a name that couldn't be read, and a group from another directory isn't counted. When the names can't be read, the table is left empty with a note saying so and the report is marked partial, so it never passes for a clean result.
Contact usCommon questions
Is it safe to remove these assignments?
Microsoft recommends removing assignments that aren't used, and an assignment to a principal that no longer exists has no one to serve. First confirm the object ID isn't a user invited in the last few minutes, and that the account running the check can read the directory.
Why does every assignment show as Unknown?
The account can't read the principals' details in Microsoft Entra ID, which is common for a guest account. Run the check again with a member account, or one that holds the Directory Readers role.
Do deleted guests show here as well?
Yes. Once a guest is deleted, its assignments look the same as any other deleted principal's. To review guests who still exist, see how to find guests with access to Azure.
Microsoft references
Technical references checked on 6 November 2026. The example scripts have been reviewed and syntax checked; they have not been run against a live tenant.
- Install-Module cmdlet reference
- Connect-AzAccount cmdlet reference
- Set-AzContext cmdlet reference
- Get-AzRoleAssignment cmdlet reference
- Disconnect-AzAccount cmdlet reference
- Troubleshoot Azure RBAC: role assignments with identity not found
- Understand Azure role assignments
- List Azure role assignments using the Azure portal
- Assign Azure roles to external users
- Managed identity best practice recommendations