How to Bulk Delete Quarantined Emails with Exchange Online PowerShell
Question details
The user needs to efficiently filter and delete a large number of quarantined email messages in Microsoft 365.

- 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.
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.
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.
Open PowerShell as an administrator and connect to your Microsoft 365 tenant using the Connect-ExchangeOnline cmdlet.
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.
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.
If you are deleting a massive batch and do not want to click 'Yes' for every email, append -Confirm:$false to the delete cmdlet.

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. Download and Install: Get WPS Office for free from the official website and install it on your device.
- 2. Open Existing Documents: Easily open your existing Microsoft Office files directly in WPS Office without any format conversion.
- 3. Edit and Save: Enjoy seamless editing and save your documents in standard Microsoft formats to share with colleagues.

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.




