How to Remove Duplicate Emails After Microsoft 365 Migration
Question details
The user needs to identify and remove duplicate emails in primary and archive mailboxes caused by restarting a migration process.

- Product
- Microsoft 365 / Exchange Online
- Device & OS
- not provided
- Scenario
- Cleaning up mailboxes after an interrupted and restarted email migration from GSuite to Microsoft 365.
- Observed behavior
- Duplicate messages are populating both the primary and archive mailboxes because the restarted migration process recopied previously migrated items.
Verify your organization's data retention requirements and back up the affected mailboxes, as deleting items via PowerShell scripts can be irreversible.
Use the Remove-DuplicateItems PowerShell Script
Run Microsoft's official Remove-DuplicateItems script via Exchange Online PowerShell to safely identify and delete duplicate messages.
Microsoft provides a dedicated PowerShell script to help Exchange administrators clean up duplicate items created during migration errors. Because this script permanently deletes data, it is crucial to test it on a single, limited mailbox before deploying it across your entire organization.
Navigate to the referenced Microsoft GitHub repository and download the `Remove-DuplicateItems.ps1` script to your local machine.
Open Windows PowerShell as an Administrator and follow Microsoft's official instructions to connect to your Microsoft 365 Exchange Online environment.
Run the `Remove-DuplicateItems.ps1` script against a limited test mailbox, carefully reviewing the command parameters to ensure you are targeting the correct duplicates.
Check the test mailbox to confirm the duplicates were removed successfully without affecting primary data, then proceed to run it for other affected mailboxes.

Streamline Your Daily Work with WPS Office
While managing complex backend Microsoft 365 email migrations requires advanced PowerShell administration, handling your daily documents, spreadsheets, and presentations doesn't have to be complicated. WPS Office offers a seamless, highly compatible, and free alternative for all your Office needs.
- 1. Download the installer: Visit the official WPS Office website and download the free installation package for your operating system.
- 2. Install the software: Run the installer file and follow the quick on-screen instructions to set up WPS Office on your computer.
- 3. Open your files: Launch WPS Office and instantly open your existing Microsoft Office documents, spreadsheets, and presentations with perfect formatting.

Frequently Asked Questions
Why do duplicate emails appear after a Microsoft 365 migration?
Duplicate emails often occur if a mailbox migration, such as moving from GSuite to Microsoft 365, is interrupted and restarted. The migration service may fail to recognize items that have already been synced, resulting in the same emails being copied again into the primary and archive mailboxes.
Where can I find the Remove-DuplicateItems.ps1 script?
The Remove-DuplicateItems.ps1 script is maintained by Microsoft and can be downloaded from their official Exchange GitHub repository.
Can I undo the deletion if the PowerShell script removes the wrong emails?
No, using the Remove-DuplicateItems script is generally a destructive and irreversible action. This is why administrators are strongly advised to run the script on a single test mailbox first and confirm data retention backups before a wider rollout.
Does this PowerShell script work for archive mailboxes as well?
Yes, the script is designed for Exchange Online and can process both primary mailboxes and archive mailboxes to remove duplicate items generated during a migration.




