Microsoft 365  

Export M365 In-Place Archive to PST Using PowerShell and Purview Portal

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 ContentMatchQuery for those folders

  • Creates 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

  1. Download the Script

  • Download the PowerShell script file from my GitHub Raw and save it as:
    In-PlaceArchiveDownload.ps1

  • šŸ“„ Download the Script Here

  1. 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
          
        
  1. Connect to Exchange Online PowerShell

  • When prompted, log in using an Exchange Online administrator account .

  1. Retrieve Mailbox Folder Details

  • Enter the mailbox email address (the one you want to export the archive from).

  1. Create a Compliance Search

  • You’ll be prompted to enter a unique name for the new Compliance Search.

  1. Connect to Microsoft Purview (Compliance Center)

  • When prompted, log in using a Compliance or Security Admin credentials .

  1. Start the Compliance Search

  • You’ll have the option to start the search immediately after creation.

  1. 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.