Deleting messages from mailboxes using Search-Mailbox

At some point, you are bound to find yourself in a situation where you need to remove an email message from one or more mailboxes. This may be due to a message being sent to one of your distribution lists or as a part of some kind of spam or virus-related outbreak.

If you have worked with Exchange 2007, you may be familiar with the Export-Mailbox cmdlet that could previously be used to perform this task. With Exchange 2010 SP1, the cmdlet Search-Mailbox was introduced. This cmdlet, which received further improvements in Exchange 2013, can be used to clean up mailboxes. In this recipe, we will take a look at how to do that.

Get Microsoft Exchange Server 2016 PowerShell Cookbook - Fourth Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.