Others

Export Microsoft 365 Email Activity Report with PowerShell

Huda QurayshiHuda Qurayshi Nov 4, 2026 868 views

Question details

The user needs to create a scheduled PowerShell script to export Microsoft 365 Email Activity reports to a CSV file and clarify role requirements.

How to Export a Microsoft 365 Email Activity Report Using PowerShell
Product
Microsoft 365
Device & OS
not provided
Scenario
Automating Microsoft 365 administration tasks to track user principal names, activity dates, and message counts.
Observed behavior
Seeking a script solution and validation on whether Global Reader and Report Reader roles provide sufficient permissions for API access.
Before you start

Before running Microsoft 365 PowerShell scripts, ensure you have the Microsoft Graph PowerShell SDK installed and have verified your tenant admin or reporting credentials.

Solution 1Recommended

Use Microsoft Graph PowerShell to Export Email Activity

The modern and recommended approach to accessing Microsoft 365 usage reports is through the Microsoft Graph PowerShell SDK.

Microsoft provides the Graph API to programmatically access usage and activity reports. You can use the Microsoft.Graph module in PowerShell to authenticate and pull this data into a structured CSV file.

1
Install the Microsoft Graph module

Open PowerShell as an administrator and run 'Install-Module Microsoft.Graph' to install the necessary SDK.

2
Connect to your Microsoft 365 tenant

Run 'Connect-MgGraph -Scopes "Reports.Read.All"' to authenticate. Your Global Reader or Report Reader account must be used here.

3
Fetch the email activity data

Use the 'Get-MgReportEmailActivityUserDetail' cmdlet to retrieve the email activity metrics, specifying the desired reporting period.

4
Export the data to CSV

Pipe the output of your query to the export command: '... | Export-Csv -Path "C:\EmailActivityReport.csv" -NoTypeInformation'. This generates the file containing user principal names and message counts.

Use Microsoft Graph PowerShell to Export Email Activity
Permissions Check: The Report Reader and Global Reader roles are sufficient to query this data via the Graph API without requiring full admin privileges.
Free Microsoft Office alternative

Edit Your Exported CSV Reports with WPS Office

While PowerShell handles the extraction of Microsoft 365 data, you need a reliable spreadsheet tool to analyze the exported CSV files. WPS Office is a highly compatible, free alternative to Microsoft Office that effortlessly handles large datasets, CSV formatting, and data visualization.

  1. 1. Launch WPS Spreadsheet: Open WPS Office on your computer and select the Spreadsheet application.
  2. 2. Open your CSV file: Click 'Open' and browse to the location where your PowerShell script saved the Email Activity CSV report.
  3. 3. Analyze the metrics: Use the Data tab tools to filter, sort, and create charts based on user principal names and message counts.
Fully compatible with Microsoft Excel (.xlsx, .xls, .csv) formats for seamless data analysis.Lightweight and fast, making it ideal for opening large PowerShell-generated CSV datasets.Provides a familiar user interface with no learning curve for Microsoft Office users.
microsoft office alternative - wps office

Frequently Asked Questions

Are the Global Reader and Report Reader roles sufficient to export Microsoft 365 usage reports?

Yes, the Report Reader role allows a user to view usage data reports in the Microsoft 365 admin center and access them programmatically via the Microsoft Graph API without needing full admin privileges. The Global Reader role also inherits this read-only access.

How can I schedule a PowerShell script to run automatically?

You can schedule a PowerShell script using the Windows Task Scheduler. Create a new task, set the trigger for your desired daily or weekly schedule, and set the action to start a program. Use 'powershell.exe' as the program and add '-File "C:\Path\To\YourScript.ps1"' in the arguments field.

Why does my exported CSV report contain formatting issues or strange characters?

This often occurs due to encoding mismatches during the export process. When using the Export-Csv cmdlet in PowerShell, append the '-Encoding UTF8' parameter to ensure all text and special characters are preserved correctly.