MSP StockroomFind a guide, template or tool…/
Curated SOPs / Microsoft 365 and identity

M365 Curated SOP / Microsoft 365 and identity

Find stale or never-used user accounts

List the user accounts in a client's Microsoft 365 tenant that have not signed in for a long time, or have never signed in.

Low risk / Read-only / Reviewed December 1, 2026

Written and maintained by MSP Stockroom. Nobody else edits it.

On this page

Before you run anything: read every command first and understand what it does. Replace example names, domains and addresses with your own. Try it on a test device or tenant before a client's. Keep client names, passwords and keys out of tickets and chat.

Purpose

List the user accounts in a client's Microsoft 365 tenant that have not signed in for a long time, or have never signed in. Leftover accounts from staff who left, test accounts and old service accounts are easy targets, because nobody notices when they are used. Use it at each quarterly review and before a licence true-up. Read-only: nothing in this SOP changes the tenant.

Scope and prerequisites

  • Run by the client's assigned engineer.
  • Needs an account with the Reports Reader role, which is the least privileged role that can read sign-in activity.
  • The tenant needs Microsoft Entra ID P1 or P2 for the last successful sign-in date.
  • The Microsoft Graph PowerShell SDK installed from the PowerShell Gallery.
  • Agree the inactivity window with the client first. Microsoft suggests 90 to 180 days.
  • Store the results in your documentation platform, never in this library.

Steps

  1. Sign in with read-only scopes:
    # Read-only scopes. You will be asked to sign in to the client's tenant.
    Connect-MgGraph -Scopes "AuditLog.Read.All", "User.Read.All"
  2. Read every user with their sign-in activity. Sign-in activity is not returned unless you ask for it:
    $days = 90
    $cutoff = (Get-Date).ToUniversalTime().AddDays(-$days)
    $users = Get-MgUser -All -Property Id, DisplayName, UserPrincipalName, UserType,
        AccountEnabled, CreatedDateTime, SignInActivity
    
    $report = $users | ForEach-Object {
        $last = $_.SignInActivity.LastSuccessfulSignInDateTime
        [pscustomobject]@{
            UserPrincipalName  = $_.UserPrincipalName
            UserType           = $_.UserType
            Enabled            = $_.AccountEnabled
            Created            = $_.CreatedDateTime
            LastInteractive    = $_.SignInActivity.LastSignInDateTime
            LastNonInteractive = $_.SignInActivity.LastNonInteractiveSignInDateTime
            LastSuccessful     = $last
            Status             = if (-not $last) { 'No successful sign-in recorded' }
                                 elseif ($last -lt $cutoff) { 'Inactive' }
                                 else { 'Active' }
        }
    }
    $report | Where-Object { $_.Status -ne 'Active' } | Sort-Object Status, UserPrincipalName

    Read the result:

    • LastInteractive is the last time someone tried to sign in by typing or tapping. It includes failed attempts, so a recent date does not prove the account is in use.
    • LastNonInteractive is the last sign-in made by an app or service for the user.
    • LastSuccessful is the last successful sign-in of either kind. It is the best guide to whether the account is really used.
    • Status Inactive: no successful sign-in inside the window. Record it.
    • Status No successful sign-in recorded: the account has never signed in, or not since December 2023, when Microsoft started recording this date. Check Created and the other two dates before you call it never used.
    • Created within the window: a new starter who has not signed in yet. Leave it off the findings.
    • Enabled False: the account is already blocked. List it separately so the client can decide whether to delete it.
  3. Count the findings for the client report:
    $report | Group-Object Status, Enabled | Select-Object Name, Count
  4. Disconnect when finished:
    Disconnect-MgGraph

Verify

Every enabled account that is inactive or has no successful sign-in has a named owner at the client and a reason to keep it, such as a shared mailbox, a break-glass admin or a service account. Anything without one goes to the client contact as a question, not a change.

Rollback

Nothing to roll back; this SOP only reads. Blocking sign-in, removing a licence or deleting an account is a separate change, made with the client's approval.

Notes

Sign-in dates can take up to 24 hours to update, though most appear within 6 hours. The dates are in UTC. LastInteractive can be blank if the last sign-in was before April 2020. Large tenants take a few minutes, because the script reads every user. Guest accounts need their own review with the guest's sponsor at the client. Microsoft covers this in its guide to stale guest accounts. See https://learn.microsoft.com/entra/identity/monitoring-health/howto-manage-inactive-user-accounts for Microsoft's guidance.

Sources and notes

Curated SOP from the MSP Stockroom SOP library (curated/m365-identity/find-stale-or-never-used-user-accounts.md). Last reviewed December 1, 2026. Tested on: Not yet run; written for Microsoft Graph PowerShell SDK 2.x; PowerShell 7.4. Vendor screens and commands change; check the vendor documentation before you rely on a step. Found a mistake? See corrections.

Search the stockroom

↑ ↓ to choose · Enter to open · Esc to close

Open the full search page →