Deleting emails from 365 using a Content Search

Sign into Office 365 admin center and view the Security and Compliance center.

Look for the “Content search” and put in the sender/subject etc.

Once the search has completed, open a Powershell Window

$UserCredential = Get-Credential


$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://ps.compliance.protection.outlook.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
Import-PSSession $Session -DisableNameChecking -allowclobber


New-ComplianceSearchAction -SearchName “contentsearchname” -Purge -PurgeType SoftDelete


New-ComplianceSearchAction -SearchName “contentsearchname” -Purge -PurgeType HardDelete


Get-ComplianceSearchAction -Purge

Leave a Reply

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