Before you delete a mailbox from Microsoft 365, it’s always a good idea making a copy of the mailbox as a backup, just in case later on there are something there you want to dig up. But how can we do that, since there is no direct way of doing it? And no, exporting the mailbox out of Outlook isn’t an option and shouldn’t be considered anyway.
In short, you start with New-ComplianceSearch to gather the information and then export the result in a PST file that you can download using eDiscovery Export Tool.
And here is how to make it happen, step-by-step.
Connecting to Compliance Service
Let’s open a PowerShell session,
$username = '[email protected]' $pwd = ConvertTo-SecureString 'pass@ord' -asplaintext -force; $cred = New-Object -TypeName PSCredential -argumentlist $username, $pwd Connect-ExchangeOnline -Credential $cred Connect-IPPSSession -Credential $cred
Once successfully connected, the right modules, along with the accessible cmdlets, will be automatically installed and imported.
Granting proper permissions
Run the following to find out who has the access to the Mailbox Search role.
Get-ManagementRoleAssignment -Role 'Mailbox Search' -GetEffectiveUsers
Add-RoleGroupMember 'Discovery Management' -member [email protected]
Note that you will need the Mailbox Search role to create searches and the Mailbox Import Export role to export or delete the search result.
Creating a new Compliance Search
Now it’s ready to create a new compliance search for a specific mailbox and run it right after.
New-ComplianceSearch 'name_of_the-search' -ExchangeLocation [email protected] | Start-ComplianceSearch
Note that it’s important to include the ‘.’ in front of the email address if it’s a shared mailbox.
You can use the Set-ComplianceSearch to reset the search query and re-run the search with Start-ComplianceSearch.
Checking the Result
Let’s log back into Microsoft 365 Compliances portal, go to Content search, and click the name of the search to find out.
From there, you can start the exporting process by clicking Action and Export results.
Downloading the PST
Once the exported data is ready for download, head over to the Export tab, and open the export detail to find out a set of Export key that you will need when downloading the data.
You will need to use Edge browser to download the data via a tool called eDiscovery Export Tool.
And that’s it.