Thursday, 29 December 2016

How to delete a single email from all user’s mailboxes in O365 server?

Or, PowerShell command to delete a single email from all user’s mailboxes in Office365 server.
Or, Email sent by mistake to all users, want to delete the specific email from everyone’s mailbox.

Descriptions: This is very common scenario where someone in your organization sent an email by mistake to a ‘Distribution List’ which may contain 100-1000 or even more users. Now the role of administrator starts here.

The requirement here is to delete this particular email from every user’s mailbox without letting them know about this.

Take it easy, you can use below PowerShell command to get it done.

Steps:
Connect to office365 server PowerShell admin console with administrative privilege.
Run below command to delete the specific email.
-----------------------------------------------------------------------------------------------------------------------------------------
$mailbox = Get-Mailbox  -ResultSize Unlimited
foreach ($Mbx in $mailbox) {
$sam = $mbx.SamAccountName
Search-Mailbox -Identity $sam -SearchQuery 'Subject:"your email subject line contents" AND From:"culprituser@domainname.com"' -DeleteContent -Force
}
-----------------------------------------------------------------------------------------------------------------------------------------

Note: Please specify “From” user’s email address and “Subject” field very carefully. Else you will end up with criticism instead of appreciation. good luck.

No comments:

Post a Comment