office 365 delete messages Search for and delete email messages – Microsoft 365

– Open Windows PowerShell as Admin
– Connect to Security & Compliance Center PowerShell

$credentials = get-credential;
Connect-ExchangeOnline -Credential $credentials
$SccSession = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri -Credential $credentials -Authentication “Basic” -AllowRedirection;
Import-PSSession $SccSession

Or Go to for more information

– Soft-delete messages

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

– Hard-delete messages

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

– Then to see progress of the action you can run


– Or specifically you can get progress of search name

Get-ComplianceSearchAction ‘NameOfTheSearch_Purge’ | Select *

Leave a Reply