Security Policy Errors

How to Bulk Delete Quarantined Emails with Exchange Online PowerShell

Emma BrownEmma Brown Oct 29, 2026 868 views

Question details

The user needs to efficiently filter and delete a large number of quarantined email messages in Microsoft 365.

How to Bulk Delete Quarantined Emails with Exchange Online PowerShell
Product
Exchange Online
Device & OS
not provided
Scenario
Managing Microsoft 365 email quarantine efficiently without manually selecting and deleting each message in the admin portal.
Observed behavior
Large volumes of quarantined emails need to be cleared out quickly, requiring a bulk deletion method via PowerShell.
Before you start

Ensure you have the necessary administrator permissions in Microsoft 365 (such as Security Administrator or Quarantine Administrator) and that the Exchange Online PowerShell module is installed and connected.

Solution 1Recommended

Bulk Delete Quarantined Messages using PowerShell Cmdlets

Filter and delete multiple quarantined emails at once by combining the Get-QuarantineMessage and Delete-QuarantineMessage cmdlets.

By using Exchange Online PowerShell, you can efficiently target quarantined messages by sender, subject, or date.

It is highly recommended to test your filters and review the output before piping the results to the delete command to prevent accidental data loss.

1
Connect to Exchange Online

Open PowerShell as an administrator and connect to your Microsoft 365 tenant using the Connect-ExchangeOnline cmdlet.

2
Filter the Quarantined Messages

Run Get-QuarantineMessage with your desired filters. For example, use Get-QuarantineMessage -SenderAddress "spam@example.com" to review the specific emails you want to target.

3
Pipe to the Delete Cmdlet

Once you have verified the filtered results, pipe them into Delete-QuarantineMessage. The command will look like: Get-QuarantineMessage -SenderAddress "spam@example.com" | Delete-QuarantineMessage.

4
Bypass Confirmation Prompts (Optional)

If you are deleting a massive batch and do not want to click 'Yes' for every email, append -Confirm:$false to the delete cmdlet.

Bulk Delete Quarantined Messages using PowerShell Cmdlets
Verify Filters First: Always run the Get-QuarantineMessage command independently first to ensure you are not accidentally targeting and deleting legitimate emails.
Free Microsoft Office alternative

Discover WPS Office for Your Daily Productivity Needs

While managing Exchange Online policies requires Microsoft admin tools, you don't need expensive Microsoft 365 subscriptions for your daily document creation. WPS Office provides a free, lightweight, and highly compatible suite for editing Word, Excel, and PowerPoint files.

  1. 1. Download and Install: Get WPS Office for free from the official website and install it on your device.
  2. 2. Open Existing Documents: Easily open your existing Microsoft Office files directly in WPS Office without any format conversion.
  3. 3. Edit and Save: Enjoy seamless editing and save your documents in standard Microsoft formats to share with colleagues.
Fully compatible with Microsoft Office formats (.docx, .xlsx, .pptx)Lightweight software that runs smoothly on Windows, Mac, and LinuxFamiliar, intuitive user interface requires no learning curveExcellent free alternative for users impacted by costly Microsoft subscriptions
microsoft office alternative - wps office

Frequently Asked Questions

Can I recover emails deleted via Delete-QuarantineMessage?

No. Once a quarantined message is deleted using the Delete-QuarantineMessage cmdlet, it is permanently removed from the quarantine and cannot be recovered.

Do I need special permissions to run Get-QuarantineMessage?

Yes, you must be assigned appropriate administrative roles in Microsoft 365, such as Security Administrator, Quarantine Administrator, or Organization Management.

How do I filter quarantined emails by date in PowerShell?

You can use the -StartReceivedDate and -EndReceivedDate parameters with the Get-QuarantineMessage cmdlet to filter messages received within a specific timeframe.

Why does Delete-QuarantineMessage prompt for confirmation on every email?

By default, destructive commands ask for confirmation to prevent accidental deletion. You can suppress these prompts by adding the -Confirm:$false parameter to your command.