skip to Main Content

Search and delete messages from Exchange user mailboxes

Today’s article will show how to search and delete messages from Exchange user mailboxes. A user sent an email to the whole organization that contains more than a thousand users, with all of them having a mailbox. The task is to delete the email from every mailbox in the organization. How to search and delete messages from Exchange user mailboxes?

Information

The only thing that we have is the subject of that email. Do you like to know how to get the subject of an email and delete that particular email from a mailbox? Read the article Delete email from Exchange user mailbox using PowerShell.

Export all users email addresses

Export all users with a mailbox to a CSV file. The CSV file will contain a list of all the email addresses. First, create a folder on your C: drive and name it temp. The folder will look like C:\temp\.

Run Exchange Management Shell as administrator. Run the cmdlet to get a list of all the email addresses of the users.

Go to the CSV file and make sure that the attribute PrimarySmtpAddress shows up. It will display on the first line.

Search and delete messages from Exchange user mailboxes CSV file

You can edit the CSV file with Microsoft Excel and remove the users you don’t want to search on. In our example, we want all of the user mailboxes and leave it as is.

Import CSV file in PowerShell

Before running the cmdlet in the next step, import the CSV file in PowerShell. It’s an excellent way to check if it’s readable and if you’re all set.

Read more: Import CSV delimiter PowerShell »

Search and delete messages from Exchange

The message that we like to delete from all Exchange user mailboxes is sent from Boris. The subject is: Saying goodbye is never easy.

Search and delete messages from Exchange user mailboxes before

Search and delete messages from CSV file

We want to search all the users in the CSV file and remove the email with that specific subject. Make sure that the -Force switch is added in the end. Otherwise, you have to keep confirming every mailbox.

It did search and delete messages from Exchange user mailboxes specified in the CSV file.

Search and delete messages from all mailboxes

If you like to target all user mailboxes without a CSV file, use the Get-Mailbox cmdlet.

It did search and delete messages from all Exchange user mailboxes.

Verify the results

Let’s have a look at Christopher’s mailbox. We can confirm that the message is deleted.

Search and delete messages from Exchange user mailboxes after

The message will not be sent to the deleted items folder. The only way to recover the message is through your back-up software.

Search and delete messages from Exchange user mailboxes recover deleted items

The message is deleted from all Exchange user mailboxes. Did this work for you?

Keep reading: Delete mailbox database Exchange 2016 »

Conclusion

You learned how to search and delete messages from Exchange user mailboxes. Get the message subject that you want to delete. After that, run one of the cmdlets shown in the article to remove the message.

Did you enjoy this article? You may also like Mark all messages as read in Outlook. Don’t forget to follow us and share this article.

ALI TAJRAN

ALI TAJRAN

ALI TAJRAN is a passionate IT Architect, IT Consultant, and Microsoft Certified Trainer. He started Information Technology at a very young age, and his goal is to teach and inspire others. Read more »

This Post Has 0 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top