Here's a sample script: https://eightwone.com/2013/06/21/removing-duplicate-items-from-a-mailbox/
Script to remove duplicate mail items after office365 migration

We recently migrated over to o365 exchange some of the mailboxes duplicated the email items.
I’m looking for a script to remove the duplicates from those mailboxes
1 additional answer
Sort by: Most helpful
-
KyleXu-MSFT 25,866 Reputation points
2021-03-08T07:47:43.623+00:00 Does the above reply helps? If the above reply helps, please be free to mark it as an answer for helping more people.
I also want to confirm with you, whether those email in the same folder? If those duplicates emails in the same folder as original email, you could use Outlook "Clean Up" function to delete them:
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.