How to Export a List of Users on Litigation Hold to CSV
Question details
The user needs to identify Exchange Online mailboxes with litigation hold enabled and export the results to a CSV file using PowerShell.
- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- Generating a compliance report of all users currently placed on litigation or legal hold in Microsoft 365.
- Observed behavior
- The goal is to successfully execute a PowerShell command to list held mailboxes and save the output as a CSV file, while avoiding formatting errors and capturing required compliance data.
Ensure that you are connected to Exchange Online PowerShell with global administrator or compliance administrator permissions, and that the destination folder for your CSV export (e.g., C:\scripts\) already exists on your computer.
Use PowerShell to Export Litigation Hold Users to CSV
Use the Get-Mailbox cmdlet combined with Select-Object and Export-Csv to generate a complete report of users on litigation hold.
This standard PowerShell method allows you to query all mailboxes and filter out the ones where LitigationHoldEnabled is set to true. It is crucial to use Select-Object rather than Format-List to ensure the data is properly structured for the CSV file.
Open PowerShell as an administrator and run 'Connect-ExchangeOnline' to authenticate with your Microsoft 365 admin credentials.
Execute the following command, ensuring there is a space before the -NoTypeInformation parameter: Get-Mailbox -ResultSize Unlimited | Where-Object {$_.LitigationHoldEnabled -eq $true} | Select-Object DisplayName,PrimarySmtpAddress,RecipientTypeDetails,LitigationHoldEnabled | Export-Csv -Path "C:\scripts\Holdreport.csv" -NoTypeInformation
Navigate to 'C:\scripts\' on your computer and open 'Holdreport.csv' in a spreadsheet application to verify that the DisplayName, PrimarySmtpAddress, and hold status were successfully captured.
Collect InPlaceHolds Data and Contact Support
If standard litigation hold queries do not capture all compliance data (such as specific InPlaceHolds), additional investigation or support is required.
Analyze Your Compliance CSV Reports with WPS Office
After exporting your litigation hold data to a CSV file using PowerShell, you need a reliable spreadsheet tool to open, filter, and analyze the results. WPS Office provides a lightweight, fast, and highly compatible alternative to Microsoft Excel for viewing and managing your compliance reports.
- 1. Download and Install WPS Office: Visit the official WPS Office website to download and install the free software suite on your computer.
- 2. Open WPS Spreadsheet: Launch WPS Office and select the Spreadsheet application from the main dashboard.
- 3. Import Your CSV Report: Click on 'Menu' > 'Open', navigate to 'C:\scripts\', and select your 'Holdreport.csv' file to view and analyze your litigation hold data.

Frequently Asked Questions
Why is my Export-Csv output showing format data instead of mailbox properties?
This happens if you use the 'Format-List' or 'Format-Table' cmdlets before 'Export-Csv'. To fix this, always use 'Select-Object' to choose your properties before piping the output to the CSV export command.
Does the Get-Mailbox command capture InPlaceHolds?
The 'LitigationHoldEnabled' property only shows mailboxes placed on an entire-mailbox litigation hold. InPlaceHolds or retention policies require checking the 'InPlaceHolds' property on the mailbox, which may require a different PowerShell script to expand and export correctly.
What permissions are required to export litigation hold users?
You must be assigned the appropriate administrator roles in Microsoft 365, such as the Exchange Administrator or Compliance Administrator role, to run the Get-Mailbox cmdlet and view litigation hold properties.
Why did I get an error saying the path could not be found?
The 'Export-Csv' cmdlet cannot create new folders. You must ensure that the directory specified in your path (e.g., 'C:\scripts\') already exists on your local machine before running the command.




