List Microsoft 365 E5 Users with Last Sign-In Time

Prev Next

Generate an audit-ready report of every E5-licensed user, their UPN, and their last interactive and non-interactive sign-in timestamps.

Complexity: Intermediate. Impact: licensing + cost-optimization + governance + audit + reporting.

Why use this workflow

Microsoft 365 E5 is typically the most expensive SKU in a tenant. Unused or rarely used E5 licenses are a common source of license waste, and stale privileged accounts holding E5 can also represent a security risk (Defender, Purview, and Entra ID P2 features attached to dormant identities).

This workflow produces a complete inventory of E5-assigned users along with their lastSignInDateTime and lastNonInteractiveSignInDateTime, sorted by recency. It is the starting point for:

  • License rightsizing (E5 > E3 downgrade candidates)
  • Quarterly access reviews of premium licenses
  • Identifying abandoned or service accounts still consuming premium SKUs
  • Feeding a finance/procurement true-up conversation with concrete data

Run it ad hoc before renewal, or on a monthly schedule as part of a broader license governance cadence.

Expected outcomes

  • The exact skuId and skuPartNumber for Microsoft 365 E5 in your tenant (commonly SPE_E5)
  • A count of consumed E5 licenses and the full list of assigned users
  • Per-user: UPN, display name, last interactive sign-in, last non-interactive sign-in
  • A CSV report suitable for sharing with security, finance, or auditors
  • A clearly identified list of users who have never signed in or who have been inactive beyond your threshold (e.g. 30/60/90 days)

Risks and considerations

  • signInActivity requires AuditLog.Read.All plus a tenant with Microsoft Entra ID P1 or P2. Free-tier tenants will receive null for all sign-in fields.
  • signInActivity cannot be combined with $filter on assignedLicenses in a single Graph call. Graph returns HTTP 400. Always fetch users and sign-in activity, then filter client-side.
  • Do not assume a null value means the account is unused. Sign-in logs are retained for a limited rolling window. A null can mean "never signed in in the retention window".
  • Non-interactive sign-ins (tokens, service principals, mail clients) can be high even when the human has left. Always check both fields before reclaiming a license.
  • Service accounts, shared mailboxes, and break-glass accounts may legitimately hold E5 with rare interactive logins. Whitelist these before any automated reclamation.
  • The report contains PII (UPN, display name, activity data). Store it in a controlled location and delete it when no longer needed.

Required permissions

PermissionWhy it's needed
Organization.Read.AllRequired to enumerate subscribedSkus and identify the E5 SKU ID in your tenant.
User.Read.AllRequired to list users and read their assignedLicenses property.
AuditLog.Read.AllRequired to read the signInActivity property (lastSignInDateTime / lastNonInteractiveSignInDateTime) on user objects.
Directory.Read.AllFallback directory read permission for license-detail and user enumeration scenarios.

Ask Dex

Paste the prompt into a Dex conversation.

Prompt for IT admins

List every Microsoft 365 E5 licensed user in our tenant with their UPN, display name, last interactive sign-in, and last non-interactive sign-in. Sort by most recent sign-in and produce a downloadable CSV. Flag any users inactive more than {inactive_days} days and any that have never signed in.

Manual steps (admin center)

Option A: Microsoft 365 admin center

  1. Sign in to the Microsoft 365 admin center as a Global Reader or License Admin.
  2. Go to Billing > Licenses.
  3. Select Microsoft 365 E5 from the license list.
  4. Click the Assigned licenses tab to see every user currently consuming an E5 license.
  5. Use Export to download the list (UPN + display name). Note: this export does not include last sign-in time.

Option B: Entra admin center (adds last sign-in)

  1. Sign in to the Microsoft Entra admin center.
  2. Go to Identity > Users > All users.
  3. Click Add filter > Assigned license > select Microsoft 365 E5.
  4. Click Columns and enable Last sign-in date (interactive) and Last sign-in date (non-interactive).
  5. Click Download users to export a CSV.

Note: The Entra portal surfaces the same signInActivity data the Graph API exposes. This requires Microsoft Entra ID P1/P2. For anything beyond a point-in-time export (scheduling, automation, cross-tenant), use the API or PowerShell path.

Microsoft Graph API

Step 1: Find the E5 SKU ID

GET https://graph.microsoft.com/v1.0/subscribedSkus?$select=skuId,skuPartNumber,consumedUnits

Look for skuPartNumber values such as SPE_E5 (Microsoft 365 E5), ENTERPRISEPREMIUM (Office 365 E5), or Microsoft_365_E5. Capture the skuId GUID.

Step 2: Enumerate users with license + sign-in activity

Do NOT combine $filter=assignedLicenses/any(...) with $select=signInActivity. Graph returns 400 Bad Request. Instead, select everything and filter client-side:

GET https://graph.microsoft.com/v1.0/users?$select=userPrincipalName,displayName,assignedLicenses,signInActivity&$top=999

Follow the @odata.nextLink until all pages are consumed.

Step 3: Filter and shape the output

Keep users where any assignedLicenses[].skuId equals the E5 skuId from Step 1. Read signInActivity.lastSignInDateTime and signInActivity.lastNonInteractiveSignInDateTime.

Example response shape

{
  "userPrincipalName": "jane.doe@contoso.com",
  "displayName": "Jane Doe",
  "assignedLicenses": [{ "skuId": "06ebc4ee-1bb5-47dd-8120-11324bc54e06" }],
  "signInActivity": {
    "lastSignInDateTime": "2026-03-26T05:00:08Z",
    "lastNonInteractiveSignInDateTime": "2026-03-26T00:40:44Z"
  }
}

Gotchas

  • signInActivity is null for tenants without Microsoft Entra ID P1/P2.
  • A null lastSignInDateTime means "no interactive sign-in within retention", not necessarily "never".
  • Use ConsistencyLevel: eventual and $count=true if you need to pair with advanced queries.

PowerShell

Install and connect once:

Install-Module Microsoft.Graph -Scope CurrentUser
Connect-MgGraph -Scopes "Organization.Read.All","User.Read.All","AuditLog.Read.All"

Approach

  • Resolve the E5 SKU dynamically rather than hard-coding a GUID, because tenant SKU IDs can vary by region and offer.
  • Request signInActivity for all users (paginated) and filter client-side, because Graph does not support $filter on assignedLicenses together with $select=signInActivity.
  • Sort descending by last interactive sign-in so stale accounts end up at the bottom of the CSV.
  • Export a CSV to a path you specify, ready for auditors or a finance handoff.

To run this monthly, schedule it with Task Scheduler or an Azure Automation runbook (with a managed identity granted the same Graph scopes).