Retrieving all Azure AD Managed Identities using the Microsoft Graph SDK for PowerShell and the Get-MgServicePrincipal cmdlet.

This code allows you to retrieve all Managed Identities. No linked subscription access is required.

The result includes where the Managed Identity is located (subscription path) and the provider type (Logic App, Automation Account etc).

Sample Output

Microsoft.HybridCompute/machines: 1000
Microsoft.Web/sites: 30
Microsoft.Management/managementGroups: 5
Microsoft.Logic/workflows: 200
Microsoft.ManagedIdentity/userAssignedIdentities: 10
Microsoft.Automation/automationAccounts: 10
Microsoft.RecoveryServices/vaults: 5
Microsoft.Authorization/policyAssignments: 20

PowerShell Code

Note: This code requires the Microsoft Graph SDK for PowerShell.