Clean up inactive guests and accounts in Entra ID
In short
Clean up inactive guest accounts and stale users by checking last sign-in dates in Microsoft Entra ID or the Microsoft Graph signInActivity property, choosing a threshold such as 90 days, and disabling before you delete. Use access reviews for guests, keep at least two documented emergency access accounts, and remove app registrations nobody has used.
Every Microsoft 365 tenant collects access that nobody uses. A contractor finishes a project and keeps their guest account. An employee leaves, and their account stays enabled. An app registration built for a pilot still holds a client secret and Microsoft Graph permissions. This post gives you a repeatable, disable-before-delete process.
What is identity sprawl?
Identity sprawl is the build-up of guests, member accounts, admin role assignments and app registrations that still have access to your tenant but no longer use it. It is one of the six kinds of sprawl in our overview of Microsoft 365 sprawl. It answers one question: who still has access they don't use?
Microsoft 365 Copilot and AI agents work within the permissions that already exist, so forgotten access becomes easier to use. Three patterns matter most:
- Stale guests keep their access. A guest invited to a team two years ago can still open everything shared with it. If their home account is compromised, so is your content.
- Unused accounts are takeover targets. Nobody notices an odd sign-in to an account nobody uses. An enabled account with a license and group memberships is a ready-made foothold.
- Unused apps keep their permissions. An app registration with a valid secret keeps working whether or not anyone remembers it. Automations and agents multiply them.
How do you find guests and users who no longer sign in?
Use the last sign-in date that Microsoft Entra ID keeps on every user object. There's no built-in inactive-user report, but Microsoft's guide to inactive accounts shows two ways to get the data. It calls 90 to 180 days a reasonable window in many organizations.
In the Microsoft Entra admin center: go to Entra ID > Users, select Manage view > Edit columns and add Last interactive sign-in time. Then filter for dates before your cutoff.
In Microsoft Graph: the signInActivity property on each user holds three timestamps. lastSignInDateTime is the last interactive attempt, including failures. lastNonInteractiveSignInDateTime is the last attempt by a client on the user's behalf. lastSuccessfulSignInDateTime is the last successful sign-in of either kind, recorded since December 1, 2023 and not backfilled. You need Microsoft Entra ID P1 or P2 and the AuditLog.Read.All and User.Read.All permissions.
A quick export with Microsoft Graph PowerShell:
Connect-MgGraph -Scopes "User.Read.All","AuditLog.Read.All"
Get-MgUser -All -Property "displayName,userPrincipalName,userType,accountEnabled,createdDateTime,signInActivity" |
Select-Object DisplayName, UserPrincipalName, UserType, AccountEnabled, CreatedDateTime,
@{n="LastSuccessful";e={$_.SignInActivity.LastSuccessfulSignInDateTime}},
@{n="LastInteractive";e={$_.SignInActivity.LastSignInDateTime}},
@{n="LastNonInteractive";e={$_.SignInActivity.LastNonInteractiveSignInDateTime}} |
Export-Csv .\last-sign-in.csv -NoTypeInformation
Three cautions. Go by LastSuccessful where it has a value, because failed attempts, such as password spraying, also update the other two columns. A blank value means the account never signed in, or last did so before April 2020, so judge it by creation date. And shared mailboxes, room accounts and service accounts often show no interactive sign-ins. Tag them and handle them separately, not in bulk.
How do you clean up inactive guests?
Find them, ask the people who work with them, then block and remove:
- Find. Filter for guests whose last sign-in is older than your threshold, plus guests who never signed in and were created before it. With Microsoft Entra ID Governance or Microsoft Entra Suite licenses, the inactive guest report under ID Governance > Dashboard does this for you. You can change its 90-day default.
- Review. Send the list to the owners of the teams, groups and sites those guests belong to. Owners know whether a partnership is still active.
- Block, then delete. Block sign-in for guests nobody vouches for, wait 30 days, then delete them. A deleted guest can be restored for 30 days, after which they need a new invitation.
To automate the loop, use Microsoft's access review for inactive guests. Review Teams + Groups (Microsoft's example uses a dynamic group of guests), scoped to guest users only. Check Inactive users (on tenant level) only and enter your number of days. Turn on Auto apply results to resource and set If reviewers don't respond to Remove access, so silence counts as a denial. Set denied guests to be blocked for 30 days, then removed. Guests invited within the inactivity window are skipped. These reviews need the same licenses.
Then slow the inflow. By default, all users, including guests, can invite external users. In Entra ID > External Identities > External collaboration settings, choose a stricter guest invite setting, such as only users in specific admin roles. Give the Guest Inviter role to those who need it. Sprawlsight's free snapshot checks this as ENTRA-032.
Should you disable or delete stale accounts?
Disable first, delete later. A disabled account can be turned back on in seconds. A deleted user can be restored for 30 days, and after that it's gone for good. For member accounts, work in this order:
- Confirm. Check with HR or the manager that the person has left or no longer needs the account.
- Disable and revoke sessions. In Entra ID > Users, open the user, edit Account status, clear Account enabled, then select Revoke sessions on the Overview page. Microsoft's guide to revoking access has the PowerShell equivalents. Disable synced accounts in on-premises Active Directory too, or sync can turn them back on.
- Hand over OneDrive files. Move anything the team still needs to a SharePoint site or the manager's OneDrive.
- Decide on the mailbox. Without a hold, removing the Exchange Online license disconnects the mailbox, and it's permanently deleted 30 days later. To keep the mail, convert it to a shared mailbox and keep the account, or put it on hold so it becomes an inactive mailbox when you delete the user.
- Remove licenses.
- Delete after a waiting period, such as 30 days disabled.
Removing the license or deleting the user makes the OneDrive unlicensed, and Microsoft makes unlicensed OneDrive accounts read-only after 60 days and archives them on day 93. Hand over files before you remove the license, never later than day 60. Deleting the user also starts the OneDrive retention period: 30 days by default, adjustable from 30 to 3,650 days in the SharePoint admin center. By default, the manager gets access and a reminder before deletion. A longer period doesn't stop the day-93 archive, and unless you pay for unlicensed OneDrive storage, Microsoft can delete the account after 365 cumulative unpaid days.
What about admins who no longer sign in?
Remove standing roles from any admin who hasn't signed in within your threshold, and use a shorter threshold for admins than for everyone else. An admin role on an account nobody uses is one of the most valuable targets in your tenant.
- List role assignments on the Roles and administrators page in Microsoft Entra ID, starting with the most privileged roles.
- Match each role holder against your sign-in export.
- Remove the role, or reassign it to someone active. With Microsoft Entra ID P2 or Microsoft Entra ID Governance licenses, make the remaining assignments eligible in Privileged Identity Management, so admins activate a role only when they need it. Schedule access reviews of those roles too.
The exception is emergency access, or break-glass, accounts. Microsoft's emergency access guidance calls for at least two cloud-only accounts on the .onmicrosoft.com domain, protected with a phishing-resistant method such as a passkey (FIDO2). Exclude them from Conditional Access policies that block or restrict sign-in, monitor them with alerts, keep them out of automated cleanup, and test them at least every 90 days. Their Global Administrator role stays permanently active, not eligible. Document them by name so nobody cleans them up by mistake. Tested accounts show recent sign-ins, so if yours don't, that's a finding. Our Microsoft 365 permissions audit maps who holds which role.
What about app registrations nobody uses?
Treat them like accounts: check the signals, confirm with an owner, soft delete, then permanently delete. A service principal is the app's identity in your tenant: the object that signs in and holds permissions.
- Sign-in activity. Entra ID > Monitoring & health > Usage & insights has Service principal sign-in activity and Application credential activity reports, both in preview. They show when each app, secret or certificate was last used. These reports need Microsoft Entra ID P1 or P2.
- Recommendations. The Remove unused applications recommendation (preview) lists apps unused for more than 90 days. It needs Microsoft Entra Workload ID Premium, a separate license.
- Context. Check the owners, the API permissions granted, and whether the app only runs at certain times, such as year-end jobs.
Deleting an app registration soft deletes it: you can restore it from App registrations > Deleted applications for 30 days. For unused apps, Microsoft advises waiting 15 days after the soft delete, then deleting permanently. Apps with expired credentials and no recent sign-ins are the easiest place to start.
What thresholds should you use for inactive accounts?
Start with 90 days for guests and app registrations, 90 to 180 days for members, and 30 to 90 days for admins. The thresholds are yours to set: write them down and apply them every quarter. The last column names the matching test in Sprawlsight's free snapshot.
| Object | Signal | Starting threshold | Action | Test |
|---|---|---|---|---|
| Guests | Last sign-in, or creation date if never signed in | 90 days | Owner or access review, block for 30 days, delete | SPR-001 |
| Member accounts | Last successful sign-in | 90 to 180 days | Disable, revoke sessions, hand over OneDrive and mail, remove licenses, delete after 30 days | SPR-002 |
| Admins | Last sign-in of every role holder | 30 to 90 days | Remove or reassign the role; keep at least two documented break-glass accounts | SPR-003 |
| App registrations | Service principal and credential last use | 90 days | Confirm with the owner, soft delete, permanently delete after waiting | SPR-004 |
Get the full playbook and checklists in the Identity Sprawl field guide.
How do you keep identity sprawl from coming back?
Automate leavers, review access on a schedule and let guest access expire. A one-off cleanup won't hold without them.
- Joiner, mover and leaver workflows. Lifecycle workflows, which need Microsoft Entra ID Governance or Microsoft Entra Suite licenses, can automate disabling and removing accounts when people leave. Without those licenses, tie a written leaver checklist to your HR process.
- Recurring access reviews. Review guests quarterly on the groups and teams with the most external collaboration, and privileged roles at least as often.
- Guest expiration. SharePoint's "Guest access to a site or OneDrive will expire automatically after this many days" setting ends a guest's access unless the person who shared, or a site owner, extends it. The guest account stays in Microsoft Entra ID. Access packages in entitlement management can also remove guests when their last assignment ends.
- A quarterly cadence. Export sign-in data, compare it with last quarter, and recheck your exceptions list: break-glass accounts, service accounts and seasonal apps.
Sprawlsight's free snapshot runs SPR-001 to SPR-004, ENTRA-032 and ODB-002 with read-only access, and you can run it again every 30 days to confirm the cleanup held. For the rest of Copilot readiness, pair this work with SharePoint oversharing cleanup and our Copilot readiness overview.
Frequently asked questions
What is identity sprawl in Microsoft 365?
Identity sprawl is the build-up of guests, member accounts, admin role assignments and app registrations that still have access to a tenant but no longer use it. Each one is access that nobody is watching. It matters more once Copilot and AI agents arrive, because they make existing access easier to use.
How long should an account be inactive before I disable it?
Microsoft's guidance on inactive accounts says a window of 90 to 180 days is reasonable in many organizations. Use a shorter window for admins, and keep a list of known exceptions such as people on leave, service accounts and emergency access accounts.
Should I disable or delete inactive accounts?
Disable first: a disabled account can be turned back on in seconds, while a deleted user can be restored for only 30 days. Disable the account, revoke sessions and hand over OneDrive files. If people need the mail, convert the mailbox to a shared mailbox and keep the account, or put it on hold, because a mailbox with no hold is deleted 30 days after its license is removed. Then remove licenses and delete after a waiting period such as 30 days.
Do I need Microsoft Entra ID Governance to remove inactive guests?
Not to do it by hand: you can filter users by last sign-in in the Microsoft Entra admin center, block guests and delete them. Sign-in activity data generally needs Microsoft Entra ID P1 or P2, which Microsoft 365 E3, E5 and Business Premium include. The inactive guest report and access reviews that remove inactive guests automatically require Microsoft Entra ID Governance or Microsoft Entra Suite licenses.
What happens to a departed user's OneDrive when I delete the account?
Deleting the user starts the OneDrive retention period: 30 days by default, adjustable from 30 to 3,650 days in the SharePoint admin center. By default, the user's manager gets access and a reminder before deletion. Whether you remove the license or delete the user, the OneDrive goes read-only after 60 unlicensed days and is archived on day 93, so finish the handover within 60 days. Unless you pay for unlicensed OneDrive storage, Microsoft can delete it after 365 cumulative unpaid days, whatever the retention setting.