Below you will find various commands useful for managing email in bulk.

Prerequisites

These commands require the ExchangeOnlineManagement module.

Commands

Import Data

New-MailboxImportRequest -Mailbox [email protected] -FilePath \\server\share\import.pst -TargetRootFolder /

Export Data

This cmdlet is available only in on-premises Exchange.

New-MailboxExportRequest -Mailbox [email protected] -ContentFilter {(Received -lt '02/01/2019')} -FilePath \\server\share\export.pst

Bulk Delete

The following script will delete all emails during the specific time range but will ignore calendar invites, contacts, and other data in the mailbox. We have to use a Do-Until loop, because -DeleteContent will only remove 20 emails at once

$mbx = get-mailbox [email protected]
Do {
    $result = Search-Mailbox -Identity $mbx.Identity -SearchQuery '(kind:email) AND (sent:01/01/2000..02/01/2019)' -DeleteContent -Force -WarningAction Silentlycontinue -DoNotIncludeArchive
    write-host $result.resultitemscount -ForegroundColor Green
} Until ($result.resultitemscount -eq 0)

More Information

New-MailboxImportRequest

New-MailboxExportRequest

Search-Mailbox