Nicholas Quirk
Systems Administrator
Documentation / Auditing third-party enterprise app permissions in Entra ID

Auditing third-party enterprise app permissions in Entra ID

Goal: find apps holding delegated Graph permissions, remove excess scopes and restrict who can use each app.

1. Export every delegated grant

Connect-MgGraph -Scopes "Application.Read.All","DelegatedPermissionGrant.Read.All","Application.ReadWrite.All","DelegatedPermissionGrant.ReadWrite.All"

$sps = @{}
Get-MgServicePrincipal -All | ForEach-Object { $sps[$_.Id] = $_.DisplayName }

Get-MgOauth2PermissionGrant -All | ForEach-Object {
    [pscustomobject]@{
        App         = $sps[$_.ClientId]
        ConsentType = $_.ConsentType   # AllPrincipals = tenant-wide, Principal = one user
        Scope       = $_.Scope.Trim()
        GrantId     = $_.Id
    }
} | Sort-Object App | Export-Csv .\app-grants.csv -NoTypeInformation

2. Review each app

  • Is it still used, and who approved it?
  • Are the scopes proportionate? Mail.ReadWrite or Files.ReadWrite.All on a tool that only needs User.Read is a red flag.

3. Reduce scopes

Update-MgOauth2PermissionGrant -OAuth2PermissionGrantId <GrantId> -Scope "User.Read"

4. Restrict access to approved users

Update-MgServicePrincipal -ServicePrincipalId <SpObjectId> -AppRoleAssignmentRequired:$true

Then assign the approved user or group under Enterprise applications, Users and groups.

5. Record the change

Log the before and after scopes and the business owner who approved the change.

Reference runbook. Test commands in a non-production tenant first and adapt names to your environment.