logo
search
Others

Delete Exchange Mailbox Emails by Date Range Using PowerShell

Elise WilliamsElise Williams Oct 10, 2026 869 views

Question details

The user needs PowerShell commands to search an on-premises Exchange mailbox, export emails within a specific date range to a network PST file, and subsequently delete them.

Delete Exchange Mailbox Emails by Date Range Using PowerShell
Product
Microsoft Exchange Server
Device & OS
not provided
Scenario
Performing administrative mailbox cleanup and archiving for an on-premises Exchange Server using EMS commands.
Observed behavior
Seeking the exact PowerShell syntax and steps to securely export and remove older messages based on specific dates.
Before you start

Ensure you are running the Exchange Management Shell as an administrator and that your account is assigned the 'Mailbox Import Export' management role to run these specific cmdlets.

Solution 1Recommended

Use Exchange Management Shell Cmdlets

Utilize built-in Exchange Management Shell (EMS) commands to filter messages by date, export them to a network PST, and then delete the items.

Managing on-premises Exchange mailboxes requires the use of the Exchange Management Shell. The process involves two primary steps: exporting the data using New-MailboxExportRequest and then deleting the content using the Search-Mailbox cmdlet.

1
Open Exchange Management Shell

Log in to your on-premises Exchange Server and launch the Exchange Management Shell (EMS) as an administrator.

2
Export Emails to a Network PST

Use the New-MailboxExportRequest cmdlet with the -ContentFilter parameter to isolate the date range and export the data to your network path. Example: New-MailboxExportRequest -Mailbox "UserAlias" -ContentFilter {(Received -lt '01/01/2023')} -FilePath "\\server\share\user.pst"

3
Delete the Exported Emails

After confirming the PST export was successful, use the Search-Mailbox cmdlet with the -DeleteContent switch to permanently remove the emails. Example: Search-Mailbox -Identity "UserAlias" -SearchQuery "Received:<01/01/2023" -DeleteContent

Use Exchange Management Shell Cmdlets
Consult Microsoft Q&A Specialists: For highly customized or complex scripts specifically tailored to your organization's on-premises environments, consulting the dedicated Exchange Server Management section on Microsoft Q&A is highly recommended.
Free Microsoft Office alternative

Manage Your Daily Documents Easily with WPS Office

While Exchange Server manages your enterprise emails, you can effortlessly handle your daily reports, spreadsheets, and presentations with WPS Office. It provides a lightweight, highly compatible, and free alternative to Microsoft Office.

  1. 1. Download the Installer: Visit the official WPS Office website and download the free installation package for your operating system.
  2. 2. Install the Software: Run the downloaded setup file and follow the simple on-screen instructions to complete the installation.
  3. 3. Start Creating: Open WPS Office and immediately start creating or editing your documents, spreadsheets, and presentations.
Fully compatible with Microsoft Word, Excel, and PowerPoint file formats.Lightweight application that runs smoothly and efficiently on almost any device.Built-in PDF editing tools for seamless document management.Familiar tabbed user interface, requiring zero learning curve to migrate.
QA img-9

Frequently Asked Questions

Do I need special permissions to export and delete Exchange emails via PowerShell?

Yes, your administrator account must be specifically assigned the 'Mailbox Import Export' management role to run the New-MailboxExportRequest and Search-Mailbox cmdlets.

Can I use Exchange Online PowerShell to manage on-premises mailboxes?

No, you must use the on-premises Exchange Management Shell (EMS) for on-premises servers. Exchange Online PowerShell is exclusively designed for Microsoft 365 cloud environments.

How can I verify the emails before permanently deleting them from the mailbox?

You can use the Search-Mailbox cmdlet with the -LogOnly and -TargetMailbox parameters. This generates a detailed report of the emails that match your specific date range before you execute any deletion commands.