TechBuzzPro

Export Inactive Microsoft 365 Users: Step-by-Step Guide

· 5 min read · Apps & Browsers

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

To export inactive Microsoft 365 users, you first need to identify them—typically by filtering for accounts that haven't signed in for a set period—then export the list to a CSV file. The most reliable method is to use the Microsoft 365 admin center's built-in export for a filtered user list, or for more control, use PowerShell to query sign-in activity and export the results. This guide walks you through both approaches, explains what you need beforehand, and covers common pitfalls and troubleshooting.

What You'll Need

  • Global administrator or at least User administrator rights in the Microsoft 365 admin center.
  • Access to the Microsoft 365 admin center (admin.microsoft.com) via a web browser.
  • For the PowerShell method: a Windows PC with the Microsoft Graph PowerShell SDK installed, or the Azure AD PowerShell module (deprecated but still functional for some tasks). We recommend the Graph SDK for future-proofing.
  • A way to open and edit CSV files (Excel, Notepad, etc.).

Step-by-Step

Method 1: Using the Microsoft 365 Admin Center (simple export)

  1. Sign in to the Microsoft 365 admin center at admin.microsoft.com with an admin account.
  2. In the left navigation pane, expand Users and select Active users. (Menu labels may vary slightly by version or region.)
  3. On the Active users page, you'll see a list of users. To find inactive users, you can sort by the Sign-in status column or use the filter. Click Filter, choose Sign-in status, and select Never signed in or Inactive (if available). Note: The admin center shows sign-in status but not the exact last sign-in date for all users; for precise inactivity periods, use PowerShell.
  4. After filtering, click Export users (or the export icon) to download a CSV file of the current view. This file includes user details but may not include last sign-in date.
  5. Open the CSV to review the list. You can now take action (e.g., disable accounts, reassign licenses).

Note: The admin center's export does not include the last sign-in date by default. For that, use Method 2.

Method 2: Using PowerShell to export inactive users with last sign-in date

  1. Install the Microsoft Graph PowerShell SDK if you haven't already. Open PowerShell as administrator and run: Install-Module Microsoft.Graph -Scope CurrentUser. Confirm any prompts.
  2. Connect to Microsoft Graph by running: Connect-MgGraph -Scopes "User.Read.All", "AuditLog.Read.All". Sign in with your admin account when prompted.
  3. Retrieve users with their last sign-in date. Run: . This lists all users with their last sign-in timestamp.
  4. Filter for inactive users. For example, to find users who haven't signed in for 90 days, run: . Adjust the -90 as needed.
  5. Export the filtered list to CSV: Pipe the command to Export-Csv -Path "C:\InactiveUsers.csv" -NoTypeInformation. For example: ... | Export-Csv -Path "C:\InactiveUsers.csv" -NoTypeInformation.
  6. Open the CSV file to review the inactive users. You can now decide on next steps (disable, delete, etc.).

Important: The SignInActivity property requires an Azure AD Premium P1 or P2 license for each user. If you don't have that, the last sign-in date may not be available. In that case, you can use the admin center's sign-in status or audit logs (if available) as a rough indicator.

Common Mistakes

  • Not having the right permissions: Only global admins or user admins can access the admin center and run these commands. Ensure your account has the necessary role.
  • Assuming the admin center export includes last sign-in date: It doesn't. Use PowerShell for that detail.
  • Forgetting about licenses: Inactive users may still be consuming licenses. After exporting, consider removing licenses to save costs, but be careful not to disrupt active users.
  • Ignoring service accounts: Some accounts (e.g., shared mailboxes, service accounts) may appear inactive but are still needed. Review the list carefully before taking action.
  • Using the wrong date format: When filtering in PowerShell, ensure your date comparisons are correct. Use (Get-Date).AddDays(-90) as shown.

Tips

  • Run the export regularly (e.g., monthly) to keep track of inactive accounts.
  • Before disabling or deleting accounts, communicate with the user's manager or IT team to avoid accidental data loss.
  • Use the -Filter parameter in Get-MgUser to reduce the amount of data retrieved, but note that filtering on SignInActivity may not be supported directly; you may need to retrieve all and filter locally as shown.
  • If you need to export additional properties (e.g., department, license status), add them to the -Property list and Select-Object.
  • Keep a record of exports for auditing purposes.

Troubleshooting

  • PowerShell command fails with "Insufficient privileges": Ensure you signed in with an admin account and granted the required scopes. Re-run Connect-MgGraph with the correct scopes.
  • SignInActivity is null for some users: This can happen if the user has never signed in or if the license doesn't include the required premium features. Check licensing.
  • Export file is empty: Verify that your filter criteria are correct. For example, if you filter for users inactive for 90 days but all users signed in recently, the list will be empty.
  • Admin center export doesn't show expected users: The admin center may only show a subset of users. Use PowerShell for a complete list.
  • Cannot install Microsoft Graph module: Ensure you have internet access and that PowerShell is running as administrator. If behind a proxy, configure PowerShell to use it.

Frequently Asked Questions

Can I export inactive users without PowerShell?

Yes, you can use the Microsoft 365 admin center to filter by sign-in status and export the list, but it won't include the last sign-in date. For that detail, PowerShell is required.

What defines an "inactive" user?

There's no fixed definition; it depends on your organization's policy. Typically, a user who hasn't signed in for 30, 60, or 90 days is considered inactive. You set the threshold when filtering.

Do I need a premium license to see last sign-in dates?

Yes, the SignInActivity property in Microsoft Graph requires Azure AD Premium P1 or P2 licenses for the users you query. Without it, you may not get accurate last sign-in data.

Can I export inactive users for a specific department?

Yes, you can add the Department property to your PowerShell query and filter by it. For example, include Department in -Property and add a Where-Object clause.

What should I do after exporting inactive users?

Review the list, confirm with stakeholders, then consider disabling accounts, removing licenses, or deleting accounts according to your organization's policy. Always back up any data before deletion.

Is there a built-in report for inactive users?

The Microsoft 365 admin center has a "Usage" report that shows active users, but it doesn't list individual inactive users with last sign-in dates. For a detailed list, use PowerShell as described.