Identify Global Administrators and other privileged role holders, verify MFA coverage, detect stale accounts, and produce a least-privilege cleanup plan.
Complexity: Intermediate. Impact: security + compliance + identity + governance + audit.
Why use this workflow
Privileged roles such as Global Administrator, Application Administrator, and Privileged Role Administrator grant tenant-wide control over identity, apps, and role assignments. A single compromised or stale privileged account is one of the most common paths to a full tenant breach.
Common hardening guidance for privileged accounts includes:
- Keep the number of permanent Global Administrators small
- Require MFA on all privileged accounts, ideally phishing-resistant
- Remove or disable stale (long-inactive) privileged accounts
- Use just-in-time activation through Privileged Identity Management (PIM) rather than permanent role assignments
When to run this workflow
- Quarterly as part of an access review cadence
- Before and after any merger, acquisition, or organizational change
- When you prepare for a security audit (for example SOC 2, ISO 27001, or HIPAA)
- After any suspected admin compromise
Expected outcomes
- A complete inventory of every user holding
Global Administrator,Application Administrator, orPrivileged Role Administrator - MFA status and registered authentication methods for each privileged user
- Last interactive and non-interactive sign-in timestamps
- A staleness flag for accounts inactive beyond your threshold
- A risk rating (Critical, High, Medium, Low) per account
- A CSV report suitable for audit evidence
- A prioritized least-privilege cleanup plan
Risks and considerations
- Do not remove your own Global Administrator role without first confirming that at least one other enabled, MFA-protected Global Administrator exists. You can lock yourself out of the tenant.
- Maintain two break-glass (emergency access) accounts with permanent Global Administrator and strong passwords stored offline. These accounts legitimately appear stale. Exclude them from cleanup.
signInActivityrequires an Entra ID P1 or P2 license and theAuditLog.Read.Allpermission.- The
roleAssignmentsendpoint returns only active (permanent) assignments. If you use PIM, also queryroleEligibilitySchedulesfor eligible-but-not-active assignments. - Service principals and groups can also hold privileged roles. Do not assume every principal is a user.
- Never bulk-disable privileged accounts without a change window and stakeholder sign-off.
Required permissions
| Permission | Why it's needed |
|---|---|
| RoleManagement.Read.Directory | Read directory role definitions and active role assignments |
| Directory.Read.All | Resolve user objects from principal IDs |
| User.Read.All | Read user properties including accountEnabled and signInActivity |
| AuditLog.Read.All | Read signInActivity (last sign-in timestamps) on user objects |
| UserAuthenticationMethod.Read.All | Enumerate registered MFA authentication methods per user |
Ask Dex
Paste the prompt into a Dex conversation.
Prompt for IT admins
Audit all users holding Global Administrator, Application Administrator, and Privileged Role Administrator roles in our tenant. For each: verify MFA enforcement and method strength, pull last sign-in activity, flag accounts inactive for more than {stale_days} days, and produce a risk-ranked CSV plus a least-privilege cleanup plan (including PIM recommendations).
Manual steps (admin center)
Step 1: Open the Roles and administrators page
- Sign in to the Microsoft Entra admin center as a Global Reader or higher.
- Go to Identity > Roles & admins > Roles & admins.
Step 2: Inspect each privileged role
- Open Global Administrator. Review the Assignments tab for both Active assignments and Eligible assignments (PIM).
- Repeat for Application Administrator and Privileged Role Administrator.
- For each member, select the name to open the user profile and note:
- Account enabled status
- Sign-in activity (visible on the Overview tab)
Step 3: Check MFA and authentication methods
- From each user's profile, go to Authentication methods.
- Confirm at least one strong method is registered (Microsoft Authenticator, FIDO2, or Windows Hello for Business). Phone or SMS alone is not considered phishing-resistant.
Step 4: Review sign-in activity
- Go to Identity > Monitoring & health > Sign-in logs.
- Filter by each privileged UPN. Flag any account with no interactive sign-ins within your staleness threshold as stale.
Step 5: Build the cleanup plan
- Any privileged user without MFA: remediate immediately (register a method or remove the role).
- Any stale privileged user: confirm with the manager, then remove the role or disable the account.
- Excess permanent Global Administrators: migrate the excess assignments to PIM Eligible.
The manual approach becomes slow at scale. Prefer the Graph API or PowerShell approach below.
Microsoft Graph API
The audit is a three-stage workflow: (1) enumerate target role definitions, (2) list assignments per role, (3) enrich each principal with user, sign-in, and MFA data.
1. Find role definition IDs
GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleDefinitions?$filter=displayName in ('Global Administrator','Application Administrator','Privileged Role Administrator')&$select=id,displayName2. List active assignments for each role
GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleAssignments?$filter=roleDefinitionId eq '{roleDefinitionId}'&$select=principalId,directoryScopeIdFor PIM-eligible (not yet activated) assignments:
GET https://graph.microsoft.com/v1.0/roleManagement/directory/roleEligibilitySchedules?$filter=roleDefinitionId eq '{roleDefinitionId}'3. Enrich each user with sign-in activity
GET https://graph.microsoft.com/v1.0/users/{id}?$select=id,displayName,userPrincipalName,accountEnabled,signInActivity,userTypeExample response excerpt:
{
"displayName": "Alex Example",
"userPrincipalName": "alex.example@contoso.com",
"accountEnabled": true,
"signInActivity": {
"lastSignInDateTime": "2025-02-14T22:54:03Z",
"lastNonInteractiveSignInDateTime": "2025-02-15T00:07:13Z"
}
}4. List registered authentication methods
GET https://graph.microsoft.com/v1.0/users/{id}/authentication/methodsAny method with an @odata.type other than #microsoft.graph.passwordAuthenticationMethod counts as MFA. Strong (phishing-resistant) methods are fido2AuthenticationMethod and windowsHelloForBusinessAuthenticationMethod.
Computing staleness
Flag a user as stale when now - lastSignInDateTime exceeds your threshold, or when signInActivity is null (never signed in). Exclude break-glass accounts by UPN.
PowerShell
Use the Microsoft.Graph PowerShell SDK to enumerate privileged users, check MFA, detect staleness, score risk, and export a CSV.
Prerequisites
- Install the SDK:
Install-Module Microsoft.Graph -Scope CurrentUser - Connect with the required scopes:
Connect-MgGraph -Scopes "RoleManagement.Read.Directory","Directory.Read.All","User.Read.All","AuditLog.Read.All","UserAuthenticationMethod.Read.All" - The tenant must have Entra ID P1 or P2 for
signInActivity.
Approach
- Resolve role definition IDs for the three target roles.
- Fetch all active and PIM-eligible assignments.
- Deduplicate principals and enrich each with user details, sign-in activity, and MFA methods.
- Assign a risk rating (Critical, High, Medium, Low).
- Export the results to CSV and print a summary.
Review the CSV, then use the findings to plan your cleanup: demote excess Global Administrators, convert permanent assignments to PIM-eligible, and enforce FIDO2 for admins.