How to find and delete duplicate Outlook emails in file explorer with PowerShell?

Young, Jasmin 25 Reputation points
2023-02-14T13:10:54.75+00:00

I have been given a list of 21,000 outlook emails to delete duplicates. The server uploaded incorrectly somehow.The subject of the emails is a randomly generate string so is unique. I need to delete duplicates based on email size and manually opening the email to check that the content is the same. Rather than eyeballing them and comparing them manually which will take me approximately 25 years lol, does anyone know how to do this in PowerShell?

E.g. traverse through Outlook files line by line. IF one file size matches the previous, open both emails. Compare first line of email with both emails. IF they match then delete one email. Surely this wouldn't be too difficult to do? Please help me, I cannot fathom looking at 21k emails!!

Thanks!

Windows for business | Windows Server | User experience | PowerShell
Windows for business | Windows Server | User experience | Other
{count} vote

Accepted answer
  1. Limitless Technology 44,751 Reputation points
    2023-02-16T10:14:47.88+00:00

    Hi. Thank you for your question and reaching out. I’d be more than happy to help you with your query

    If you're looking to find and delete duplicate Outlook emails in the file explorer with PowerShell, you can use the following steps:

    Open the file explorer and navigate to the Outlook Mail folder.

    Right-click the folder and select 'Open with PowerShell'.

    Type the command 'Get-ChildItem *.msg | Sort-Object -Property Subject | Select-Object -Unique' into the PowerShell window and press enter.

    Type the command 'Remove-Item -Force' and press enter.

    This command will search for and select any duplicates of Outlook emails in the folder, and then delete them. You may also need to run this command multiple times to find and delete all the duplicates.

    I hope this helps you in finding and deleting duplicates Outlook emails in the file explorer with PowerShell.

    If the reply was helpful, please don’t forget to upvote or accept as answer, thank you.

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.