How to delete an email from all users mailbox in Office 365

Share This

In this tutorial i will be shpwing you how to delete an email from anyone’s or everyone’s mailbox in Office 365 using Microsoft 365 Compliance Centre and PowerShell.

You will learn how to search for the email,  and delete the email from all users mailboxes using powershell.

Updated: This is now a video post.

The Script

# Get Microsoft 365 login credentials 
$UserCredential = Get-Credential 

# Create Exchange Admin Session
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $UserCredential -Authentication Basic -AllowRedirection 

##Import Session
Import-PSSession $Session -AllowClobber -DisableNameChecking 

#Connect to previously created search and delete items
New-ComplianceSearchAction -SearchName "Search Name" -Purge -PurgeType HardDelete

#Change HardDelete to SoftDelete if you wish to test first, Soft Delete will store the email in users 'Recoverable items' folder
Did you enjoy this article?
Signup today and receive free updates straight in your inbox. We will never share or sell your email address.

Leave a Reply

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