Showing posts with label delete emails in office 365. Show all posts
Showing posts with label delete emails in office 365. Show all posts

Thursday, January 07, 2021

Techie Post - Deleting emails from multiple mailboxes in Office 365

Occasionally I'm asked at work to delete an email that has been accidentally sent out to the wrong people.  It doesn't happen very often, but inevitably when it does happen, I forget the process, so I am including it here for personal reference.

Create a content search rule within the Microsoft 365 Compliance area - https://compliance.microsoft.com/homepage  (take note of the name you call it - you'll need it in the New-ComplianceSearchAction command.

Run Powershell as administrator and enter the following commands...

set-executionpolicy remotesigned
(only use this if you get an error about not being able to run scripts via Powershell)

$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

New-ComplianceSearchAction -SearchName "Rule Name used in content search" -Purge -PurgeType SoftDelete

If you would like to see the progress of the search, use the following command.

Get-ComplianceSearchAction