Enhanced Entra PIM for Application Roles & AI Agent Identities: Auditing App Permissions via Graph PowerShell

✨ Identity Governance Brief — Enhanced Entra PIM for App Roles & AI Agents
  • What is expanding: Following Microsoft Ignite 2026, Microsoft Entra Privileged Identity Management (PIM) is expanding just-in-time (JIT) controls and AI-powered least-privilege role recommendations beyond human admins to application roles and AI agent identities.
  • Immediate Exposure: Most enterprise automation apps and AI agents hold permanent, standing Graph permissions such as Directory.ReadWrite.All or RoleManagement.ReadWrite.Directory—even when they only run read-only jobs 95% of the time.
  • First Step: Run the Microsoft Graph PowerShell audit below to inventory every Service Principal's granted appRoleAssignments and flag standing write permissions for least-privilege reduction.

Human administrators have used Microsoft Entra Privileged Identity Management (PIM) for years to replace standing Global Administrator rights with time-bound, just-in-time elevation. Yet non-human identities—enterprise automation apps, workload identities, and autonomous Entra Agent IDs—still commonly hold permanent, over-scoped Graph permissions.

With Microsoft expanding Enhanced PIM and AI-driven least-privilege recommendations to application roles and AI agent identities, every identity team should start by auditing all standing appRoleAssignments across their tenant.


Step 1: Audit All Granted Application Permissions (appRoleAssignments) via Graph PowerShell

This script resolves Microsoft Graph App Role GUIDs into human-readable permission names (e.g., Directory.ReadWrite.All, ServiceHealth.Read.All) so you can spot over-privileged apps and AI agents immediately:

POWERSHELL
Connect-MgGraph `
    -ClientId "c841ae33-4093-4385-8a90-6a530761f9b9" `
    -TenantId "ab85c7a1-366d-44ba-acc6-924fa0950045" `
    -CertificateThumbprint "BEAC429DE404B46FF030811C0C9DE00DE701C027" `
    -NoWelcome

# 1. Build a lookup table of Microsoft Graph AppRole GUIDs -> Permission names
$GraphSp = (Invoke-MgGraphRequest -Method GET `
    -Uri "https://graph.microsoft.com/v1.0/servicePrincipals?`$filter=appId eq '00000003-0000-0000-c000-000000000000'&`$select=id,appRoles").value[0]

$RoleMap = @{}
foreach ($Role in $GraphSp.appRoles) { $RoleMap[$Role.id] = $Role.value }

# 2. Inspect appRoleAssignments for a target Service Principal (or loop across all custom SPs)
$TargetSpId = "c142386f-63d7-4b1c-b2b5-ec5e9c02ab43"
$Assignments = (Invoke-MgGraphRequest -Method GET `
    -Uri "https://graph.microsoft.com/v1.0/servicePrincipals/$TargetSpId/appRoleAssignments").value

$Assignments | ForEach-Object {
    [PSCustomObject]@{
        Resource   = $_.resourceDisplayName
        Permission = if ($RoleMap[$_.appRoleId]) { $RoleMap[$_.appRoleId] } else { $_.appRoleId }
        Created    = $_.createdDateTime
    }
} | Format-Table -AutoSize

Live Output from Our LAB 365 (xzf58.onmicrosoft.com) Tenant (LAB365-Dev-Automation):

TEXT
Resource                   Permission                             Created
--------                   ----------                             -------
Microsoft Graph            User.ReadWrite.All                     11/7/2026 9:40:20 PM
Microsoft Graph            UserAuthenticationMethod.ReadWrite.All 11/7/2026 9:40:20 PM
Microsoft Graph            Directory.ReadWrite.All                11/7/2026 9:40:19 PM
Microsoft Graph            ServiceMessage.Read.All                11/26/2026 7:44:19 AM
Microsoft Graph            Group.ReadWrite.All                    11/7/2026 9:40:19 PM
Microsoft Graph            Organization.Read.All                  11/7/2026 9:40:21 PM
Microsoft Graph            RoleManagement.ReadWrite.Directory     11/7/2026 9:40:21 PM
Microsoft Graph            AuditLog.Read.All                      11/7/2026 9:40:20 PM
Microsoft Graph            ServiceHealth.Read.All                 11/26/2026 7:44:19 AM
Office 365 Exchange Online dc50a0fb-09a3-484d-be87-e023b12c6440   11/7/2026 9:40:22 PM

(Note: dc50a0fb-09a3-484d-be87-e023b12c6440 is Exchange Online's Exchange.ManageAsApp role.)


Step 2: Least-Privilege & PIM Hardening Checklist

  1. Split Read-Only vs. Write Automation Apps: Move monitoring scripts (ServiceHealth.Read.All, AuditLog.Read.All, Organization.Read.All) onto a dedicated read-only Service Principal separate from apps holding *.ReadWrite.All.
  2. Apply Dynamic Permissions & PIM Recommendations: Review Entra PIM least-privilege recommendations to downgrade unused write roles and enforce task-scoped Dynamic Permissions for AI agents (Governing AI Agent Dynamic Permissions).
  3. Require Named Locations on Workload Identities: Pair PIM with Conditional Access for Workload Identities so app tokens are only accepted from your trusted egress IPs or Azure Managed Identity endpoints.

References & Official Microsoft Documentation

đź’¬ Reader Comments & Feedback

Did this runbook help, or did Microsoft change a cmdlet or UI menu? Share your feedback below.