There are generally two criteria to identify Microsoft 365 inactive users:
The user account hasnโt signed in within a specified period.
The user account had no recorded activities in Exchange Online, SharePoint Online, Yammer, Teams, and OneDrive, within a specified period.
Administrators can consider one or both criteria when analyzing inactive Microsoft 365 users for possible clean-up and freeing up of unused licenses.
The period by which the accounts are considered inactive is subjective. It could be the last 30 days, 90 days, etc. The organization or administrators must be the ones to nominate the optimal period of inactivity.
Microsoft Entra records several different sign-in timestamps:
Last interactive sign-in โ the last time a user signed in interactively (browser, desktop app, MFA).
Last non-interactive sign-in โ authentication performed by background services, refresh tokens, or apps.
Last successful sign-in โ the last successful authentication regardless of sign-in type.
Depending on your licensing and reporting requirements, these timestamps may provide a more accurate picture of actual user activity.
Find Inactive Users in Microsoft Entra Admin Center by Sign-In Activity
The Microsoft Entra admin center (formerly Azure Active Directory Admin Center) provides a user-friendly interface to manage user accounts and activities. The Microsoft Entra admin center currently exposes the Last sign-in time column in the Users view. If your tenant also exposes Last successful sign-in, prefer using it because it more accurately reflects successful authentication. To find inactive users based on their last successful sign-in date, follow these steps:
Log in to Microsoft Entra and navigate to Identity โ Users โ All Users.
Click Manage view โ Edit columns.
Customize the columns and ensure that either Last successful sign-in (preferred) or Last sign-in time is visible. Then click Save.
Click Add filter and select Last successful sign-in if available; otherwise use Last sign-in time.
Change the Operator to โ<=โ (less than or equal to), specify the Value (date) threshold, and click Apply. This filter only shows accounts that last signed in on or before the selected date.
You now have a list of inactive Microsoft 365 users who have not signed in to their accounts within the previous number of days. Click โDownload usersโ, enter the filename to generate the Microsoft 365 inactive users report CSV file, and click Start.
Click the โBulk operation resultsโ menu blade and select the report from the list. Note that the status should be โCompletedโ before downloading the report.
Click the โDownload resultsโ link, specify the filename and location, and click Save. Youโve now downloaded the Microsoft 365 Inactive users report.
Depending on your Microsoft Entra tenant and licensing, additional sign-in properties (such as Last successful sign-in and Last non-interactive sign-in) may also be available. These values often provide a more accurate representation of user activity than the legacy Last sign-in time field.
Note that access to detailed sign-in activity requires Microsoft Entra ID P1/P2 licensing. Keep in mind that available sign-in properties may vary depending on your tenant license.
Find Inactive Users in Microsoft 365 using Microsoft 365 Admin Center by the Last Activity Date
Like the previous method, you can find inactive users based on their last activity date. The data can be found in the usage reports. Hereโs how:
Log in to the Microsoft 365 Admin Center.
Navigate to Reports โ Usage โ Microsoft 365 apps โ Active Users. Select the reporting period, such as โPast 90 daysโ. Doing so will show the activity logs in the past 90 days.
Here you can find out which users have licenses assigned but had no activities within the specified reporting period.
You can also export this report by clicking the Export button and downloading the resulting CSV file.
Generate Microsoft 365 Inactive Users Report using Microsoft Graph PowerShell by the Last Successful Sign-In
For those who prefer a more automated approach, Microsoft Graph PowerShell can be a powerful tool. This method lets you generate detailed reports on inactive users based on their last successful sign-in. Hereโs how:
First, copy the script below and save it to your computer as Get-InactiveUsersByLastSuccessfulSignIn.ps1. You can also download the code from this link.
# Get-InactiveUsersByLastSuccessfulSignIn.ps1
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[int]
$DaysWithoutSuccessfulSignIn
)
# Convert the date to datetimeoffset "yyyy-MM-ddThh:mm:ssZ" format.
$OnOrBefore = ((Get-Date).AddDays(-$DaysWithoutSuccessfulSignIn)).ToString("yyyy-MM-ddT00:00:00Z")
# Compose the API filter $filter = ('signInActivity/LastSuccessfulSignInDateTime le ' + $OnOrBefore)
try {
# Import the required module
Import-Module Microsoft.Graph.Users
# Get users and
Get-MgUser -All -Filter $filter -ErrorAction Stop -Property `
'DisplayName', 'UserPrincipalName', 'Mail', 'UserType', 'AccountEnabled', 'SignInActivity' |
Select-Object 'DisplayName', 'UserPrincipalName', 'Mail', 'UserType', 'AccountEnabled',
@{n='LastSuccessfulSignInDate';e={
$(
if (!$_.SignInActivity.LastSuccessfulSignInDateTime) {
# Users who have never signed in are assigned the minimum DateTime value.
[datetime]::MinValue
}
else {
$_.SignInActivity.LastSuccessfulSignInDateTime
}
)
}
},
@{n='DaysWithoutSuccessfulSignIn'; e = {
$(
if (!$_.SignInActivity.LastSuccessfulSignInDateTime) {
# Users who have never signed in are assigned the minimum DateTime value.
(New-TimeSpan -Start ([datetime]::MinValue)).Days
}
else {
(New-TimeSpan -Start ($_.SignInActivity.LastSuccessfulSignInDateTime)).Days
}
)
}
}
}
catch {
$_.Exception.Message | Out-Default
return $null
}
Open PowerShell and change the working directory to where you saved the script.
Set-Location <script location>
Run the following command to connect to Microsoft Graph. This connection explicitly requests the AuditLog.Read.All and User.Read.All API permissions.
This example finds Microsoft 365 users whose last successful sign-in occurred more than 30 days ago. You can also export the results to a CSV file by piping it to the Export-Csv cmdlet.
This method requires the latest Microsoft Graph PowerShell SDK. You need to install/update the Microsoft.Graph module before running the script. Refer to this Microsoft Document.
Generate Microsoft 365 Inactive Users Report using Microsoft Graph PowerShell by the Last Activity Date
Similar to the previous method, you can generate an inactive Microsoft 365 users report based on the last activity date.
Users assigned licenses, such as Exchange, SharePoint, Teams, OneDrive for Business, and Yammer, are expected to use those services. If not, it would be best to know who isnโt using their Microsoft 365 services.
Copy the script below and save it to your computer with the filename Get-InactiveUsersByLastActivityDate.ps1. You can also download the script from this link.
Click โAcceptโ to consent to the requested permissions. Note. Older Microsoft Graph PowerShell examples often use the Microsoft.Graph.Beta modules because the SignInActivity property was originally available only through Microsoft Graph Beta. Current Microsoft Graph SDK releases expose this functionality through the stable modules in most environments, so you should use Microsoft.Graph unless a specific feature still requires the Beta SDK.
Execute the script as shown below. Adjust the -DaysWithoutActivity value as needed.
This example will find inactive users in Microsoft 365 whose last activity in Exchange, Teams, OneDrive, SharePoint, and Yammer is beyond the past 30 days.You can also export the results to a CSV file by piping it to the Export-Csv cmdlet.
Not necessarily. A user may rarely sign in but still receive email or access services through automated processes. Always review business requirements before disabling accounts or reclaiming licenses.
Yes. Both the Microsoft Entra admin center and Microsoft 365 Admin Center allow you to export reports as CSV files. Microsoft Graph PowerShell scripts can also pipe results directly to Export-Csv for further analysis or automation.
June started in IT back in 2002. Since then, he has worked as a programmer, technical support specialist, and systems administrator. He is currently a technology consultant working with Microsoft 365, Azure, and various Messaging and Collaboration systems. June is always on the lookout for automation opportunities and prefers to write code in PowerShell whenever possible.