Others

How to Export Exchange Online Mailbox Last Logon Data to CSV

Kushani NimanthikaKushani Nimanthika Nov 2, 2026 869 views

Question details

An administrator needs to extract Exchange Online mailbox information, including email addresses, last logon times, and assigned Microsoft 365 licenses, into a consolidated CSV report.

Export Exchange Online Mailbox Last Logon Data to CSV
Product
Exchange Online / PowerShell
Device & OS
not provided
Scenario
IT administrators frequently need to audit Microsoft 365 environments to identify inactive mailboxes, reclaim unused licenses, or generate compliance reports.
Observed behavior
Extracting last logon time requires Exchange Online modules, while license information requires Microsoft 365 modules. The challenge is running the correct PowerShell commands and combining the outputs into a single CSV file.
Before you start

Ensure you are running PowerShell as an Administrator and have the ExchangeOnlineManagement and MSOnline (or AzureAD) PowerShell modules installed and authenticated.

Solution 1Recommended

Export Mailbox Statistics and Last Logon Time to CSV

Use this method to quickly generate a CSV file containing user display names, email addresses, and their most recent logon times using the Exchange Online module.

This approach uses the standard Exchange Online PowerShell cmdlets to retrieve mailbox statistics across your entire organization.

1
Connect to Exchange Online

Open PowerShell as Administrator and run 'Connect-ExchangeOnline'. Sign in with your global or exchange administrator credentials when prompted.

2
Run the Export Command

Execute the following command to retrieve the data and export it: Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName, UserPrincipalName, LastLogonTime | Export-Csv 'C:\lastlogon.csv' -NoTypeInformation.

3
Verify the Exported File

Navigate to the C:\ directory on your computer, locate the 'lastlogon.csv' file, and open it in your preferred spreadsheet software to verify the data.

Export Mailbox Statistics and Last Logon Time to CSV
Command Successful: Using the -NoTypeInformation parameter ensures your CSV file does not contain unnecessary header metadata, making it cleaner to open in spreadsheet applications.
Free Microsoft Office alternative

Analyze Exchange Online CSV Reports with WPS Spreadsheet

After exporting your Exchange Online last logon and license data via PowerShell, you need a reliable spreadsheet tool to review the CSV files. WPS Office provides a free, lightweight alternative to Microsoft Excel, offering seamless format compatibility and a familiar UI for data analysis.

  1. 1. Install WPS Office: Download and install WPS Office on your computer.
  2. 2. Open Your CSV Export: Right-click the 'lastlogon.csv' file generated by PowerShell and select 'Open with WPS Spreadsheet'.
  3. 3. Analyze Data: Apply data filters and conditional formatting to quickly spot accounts that have not logged in recently.
Fully compatible with Microsoft Excel CSV, XLSX, and XLS formats.Easily filter, sort, and analyze large mailbox statistics exports to identify inactive users.Lightweight software that runs smoothly on Windows, Mac, and Linux systems.Familiar spreadsheet interface for seamless migration and zero learning curve.
microsoft office alternative - wps office

Frequently Asked Questions

Why is the LastLogonTime blank for some of my users?

A blank LastLogonTime typically means the user has never logged into their mailbox. It can also occur if a mailbox was recently migrated and hasn't been accessed in the new Exchange Online environment yet.

Can I filter the PowerShell export for specific departments?

Yes. You can modify the Get-Mailbox command by adding filters, such as Get-Mailbox -Filter {Department -eq 'Sales'}, before piping the results into Get-MailboxStatistics.

How do I fix formatting issues when opening the exported CSV?

If all your data appears squished into a single column, your system's default list separator might differ from the comma used by PowerShell. You can fix this by opening the file in WPS Spreadsheet, selecting the column, and using the 'Text to Columns' feature under the Data tab to split the text by commas.