Find Last Logon Time of Users in Microsoft 365 Using Microsoft Graph PowerShell (signInActivity)

✨ Executive Summary — Auditing User Last Sign-In Time in Microsoft 365 (2026)
  • Legacy Cmdlets Retired: Get-MsolUser and Get-AzureADUser are retired, and Get-MailboxStatistics LastLogonTime only reflects background mailbox assistant touches—not actual user logins.
  • Authoritative Source (signInActivity): Use Microsoft Graph PowerShell (Get-MgUser -Property SignInActivity) with AuditLog.Read.All to retrieve both lastSignInDateTime (interactive) and lastNonInteractiveSignInDateTime (token refreshes).
  • Exchange Mailbox Activity: For mail-specific activity, pair Graph sign-ins with Get-EXOMailboxStatistics -Properties LastUserActionTime in Exchange Online PowerShell v3.

One of the most common tasks for Microsoft 365 administrators—whether reclaiming unused licenses, offboarding stale accounts, or passing a SOC 2 / ISO 27001 audit—is generating an accurate Last Logon Time report for all users in the tenant.

In older Office 365 guides, admins relied on Get-MailboxStatistics | Select LastLogonTime or MSOnline. Today, LastLogonTime in Exchange Online is misleading because background Exchange services, folder assistants, and Teams/Copilot substrate syncs update it even when a human hasn't signed in for months.

In this modernized 2026 Runbook, we show how to query the authoritative signInActivity resource in Microsoft Graph PowerShell (Get-MgUser) and export a clean stale-user CSV report.


Architecture: Choosing the Right Last Logon Signal

Microsoft 365 User Activity Signals: Entra signInActivity vs. Exchange Online 1. ENTRA INTERACTIVE lastSignInDateTime • Password, MFA, Passkey prompts • Best for human login tracking Requires AuditLog.Read.All 2. NON-INTERACTIVE lastNonInteractiveSignInDateTime • Silent OAuth refresh tokens • Outlook, Teams, Mobile syncs Catches active silent sessions 3. EXO USER ACTION LastUserActionTime • True Outlook/OWA user action • Ignores background assistants ExchangeOnlineManagement v3+

Step 1: Query Last Sign-In Time via Microsoft Graph PowerShell (signInActivity)

Make sure your app registration or interactive session has AuditLog.Read.All and User.Read.All permissions (and an Entra ID P1/P2 license in the tenant for signInActivity).

POWERSHELL
# Connect to Microsoft Graph (App-Only Certificate Auth)
Connect-MgGraph `
    -ClientId "c841ae33-4093-4385-8a90-6a530761f9b9" `
    -TenantId "ab85c7a1-366d-44ba-acc6-924fa0950045" `
    -CertificateThumbprint "BEAC429DE404B46FF030811C0C9DE00DE701C027" `
    -NoWelcome

# Retrieve all users with SignInActivity
$Users = Get-MgUser -All -Property Id, DisplayName, UserPrincipalName, AccountEnabled, UserType, SignInActivity

$Report = foreach ($User in $Users) {
    $LastInteractive    = $User.SignInActivity.LastSignInDateTime
    $LastNonInteractive = $User.SignInActivity.LastNonInteractiveSignInDateTime

    # Pick the most recent timestamp across interactive & non-interactive sign-ins
    $LatestActivity = @($LastInteractive, $LastNonInteractive) |
        Where-Object { $_ -ne $null } |
        Sort-Object -Descending |
        Select-Object -First 1

    $DaysInactive = if ($LatestActivity) {
        [math]::Round(((Get-Date).ToUniversalTime() - $LatestActivity.ToUniversalTime()).TotalDays, 0)
    } else {
        "Never / >90d"
    }

    [PSCustomObject]@{
        DisplayName        = $User.DisplayName
        UserPrincipalName  = $User.UserPrincipalName
        AccountEnabled     = $User.AccountEnabled
        UserType           = $User.UserType
        LastInteractive    = $LastInteractive
        LastNonInteractive = $LastNonInteractive
        DaysInactive       = $DaysInactive
    }
}

$Report | Format-Table -AutoSize
$Report | Export-Csv -Path ".\M365_User_LastSignIn_Report.csv" -NoTypeInformation -Encoding UTF8

Live Output from Our LAB 365 (xzf58.onmicrosoft.com) Tenant:

TEXT
DisplayName UserPrincipalName           AccountEnabled LastInteractive        LastNonInteractive
----------- -----------------           -------------- ---------------        ------------------
Abhishek    [email protected]                        True 10/27/2023 12:59:28 PM 10/27/2023 12:59:34 PM
Adele Vance [email protected]                         True 2/21/2024 9:33:16 AM   2/21/2024 12:21:56 PM
Alex Wilber [email protected]           True 3/30/2023 7:23:46 PM
Anand       [email protected]                       True 8/31/2023 12:37:31 PM  8/31/2023 1:24:53 PM
arun Kumar  [email protected]           True
Note on Empty Values: If LastInteractive and LastNonInteractive are blank, the user has never signed in—or their last sign-in occurred before Microsoft Entra began retaining signInActivity for that account.

Step 2: Cross-Check True Email Activity with Get-EXOMailboxStatistics

If you specifically need to verify when a user last opened Outlook, OWA, or Exchange ActiveSync (excluding background mailbox assistants), query LastUserActionTime using the Exchange Online PowerShell v3 (ExchangeOnlineManagement) module:

POWERSHELL
Connect-ExchangeOnline -ShowBanner:$false

Get-EXOMailbox -ResultSize Unlimited -RecipientTypeDetails UserMailbox | ForEach-Object {
    $Stats = Get-EXOMailboxStatistics -Identity $_.UserPrincipalName -Properties LastLogonTime, LastUserActionTime -ErrorAction SilentlyContinue
    [PSCustomObject]@{
        DisplayName        = $_.DisplayName
        UserPrincipalName  = $_.UserPrincipalName
        LastUserActionTime = $Stats.LastUserActionTime
        LastLogonTime      = $Stats.LastLogonTime
    }
} | Export-Csv -Path ".\EXO_Mailbox_LastUserAction.csv" -NoTypeInformation -Encoding UTF8

References & Official Microsoft Documentation

đź’¬ Reader Comments & Feedback

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