Delete specific email from mailbox using powershell

In this article, I am going to show you how to delete the specific email that from a mailbox that already sent.

HR called me and asked if I can delete specific email from all mailboxes immediately because they have written something by mistake.

In the old exchange versions, we could use on “MFCMAPI /MDBVU32.EXE” which helped us to locate emails that already sent and delete them, in Exchange 2007,2010,2013 we can even search specific email on the specific mailbox and delete an email without the user aware, using PowerShell.

Before we are starting we have made sure we are a member of “Discover Mailbox” group and Administrator. you can check it by running on PowerShell this command:

Cmdlet Search-Mailbox.

We have to use in Exchange Powershell.

With the following context, we can specify the subject, username, and just delete it:

Search-Mailbox -Identity “username ” -SearchQuery ‘Subject:” XXXX “‘ –DeleteContent Attachments

If you want, you can search other parameters such as:

CC

From

Sent

Subject

To

If you want to search email globally or on specific DL you suppose to use this context:

get-content all user or group.txt | Get-Mailbox -ResultSize Unlimted | Search-Mailbox –SearchQuery ‘ XXXX ‘ -TargetMailbox ” Mailbox Name ” -TargetFolder “Name of folder”