Search and remove mails in exchange accounts

Search and remove mails in exchange accounts

In this post, I will show you how to, in the case of receiving a spam message that has been sent to all accounts within our tenant, search for that message and remove it from the mailboxes.

As I mentioned in the previous post, we first need to import the ExchangeOnline module and log in to PowerShell with an Office 365 administrative account.

Now we can proceed with searching for emails. Before starting the search, we need to define the criteria by which we want to conduct the search.

I provided some examples above on how to search for emails. Once you have defined the search criteria, you can go ahead and initiate the search.

To check the status of the search, you can use the command:

Once the search status is completed, you can view on which mailboxes the specific email was found.

Now, you need to delete all the messages that were found. There are two deletion options – Soft and Hard. The first option deletes the message, but the user has the option to restore it from the Deleted Items, while the second option permanently deletes the message.

Comments

No comments yet. Why don’t you start the discussion?

Leave a Reply

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