In Microsoft 365, exporting only the In-Place Archive mailbox to PST isn't straightforward.
While the normal Content Search in Microsoft Purview includes both the primary and archive mailboxes, there's no direct option to select the archive mailbox alone.
To solve this, I wrote a PowerShell script that helps you create a targeted Compliance Search for all folders inside the archive mailbox allowing you to export only archive data later via the Purview portal .
What the Script Does
This PowerShell script:
Connects to Exchange Online and Microsoft Purview (Compliance Center)
Retrieves all folder IDs from the specified mailbox's In-Place Archive
Builds a combined
ContentMatchQueryfor those foldersCreates and optionally starts a Compliance Search for archive-only content
Allows you to later export and download the search results as a PST file via Purview Portal
Prerequisites
To run this script successfully, make sure:
In Exchange Online
You have the Exchange Administrator role.
This role provides the required access to connect to Exchange Online PowerShell and retrieve mailbox folder statistics.
In Microsoft Purview
You must have permissions to:
Create and run Compliance Searches
Export Content Search results
(These are typically included in the eDiscovery Manager or Compliance Administrator roles.)
PowerShell Modules Required
Make sure these modules are installed and updated:
Install-Module ExchangeOnlineManagement -Force
Import-Module ExchangeOnlineManagement
You'll also need the Security & Compliance PowerShell module for connecting to Purview:
Connect-IPPSSession
Execution Workflow
Download the Script
Download the PowerShell script file from my GitHub Raw and save it as:
In-PlaceArchiveDownload.ps1
Launch PowerShell and Run the Script
Open Windows PowerShell (Run as Administrator).
Navigate to the folder where the script is saved.
cd "C:\Path\To\Script"Execute the script:
.\In-PlaceArchiveDownload.ps1
Connect to Exchange Online PowerShell
When prompted, log in using an Exchange Online administrator account .
Retrieve Mailbox Folder Details
Enter the mailbox email address (the one you want to export the archive from).
Create a Compliance Search
You’ll be prompted to enter a unique name for the new Compliance Search.
Connect to Microsoft Purview (Compliance Center)
When prompted, log in using a Compliance or Security Admin credentials .
Start the Compliance Search
You’ll have the option to start the search immediately after creation.
Export and Download PST from Purview
Open the Microsoft Purview Portal → navigate to Content Search .
Locate the Compliance Search name you created.
Select Export Results → PST format .
Once the export completes, download the PST file directly from the portal.
Benefits of Using This Automation
✅ Automates a manual multi-step process
✅ Integrates seamlessly with Purview eDiscovery
✅ Saves administrative time and effort
🏁 Conclusion
Exporting data from In-Place Archive mailboxes in Microsoft 365 has always been a tedious and partially manual process.
This PowerShell automation provides a reliable and repeatable way to:
Collect all archive folder IDs
Build a comprehensive search query
Create and start a Compliance Search
Export results as a PST file through Microsoft Purview
With the right permissions and setup, this script can significantly simplify archive mailbox export tasks for Exchange Online administrators.
Amit AroraPosted May 13, 2026, 9:52 PM
Its throwing an error. I have checked all permissions but no luck.. [ERROR] Failed to start Compliance Search: |Microsoft.Exchange.Configuration.Tasks.ThrowTerminatingErrorException|Unable to execute the task. Reason: Please close the current PowerShell session and open a new session using Connect-IPPSSession with the -EnableSearchOnlySession flag. This requires using ExchangeOnlineManagement v3.9.0 or higher. If you already do that, the failed reason is Compliance search initialization for "Computer" failed with exception: An error occurred while sending the request..
Bob KennyPosted Mar 12, 2026, 10:42 AM
Hello, is this script able to export also item from auto expanding in-place archives?