Sometimes you need to remove a special email from ALL mailboxes on your exchange server. This is quite easy via the powershell.

At first, make sure that the account running the powershell command has the appropriate permissions. If you don’t have the correct permissions you will get an error “The term ‘xxxxxxxxx’ is not recognized as the name of a cmdlet”.

To delete a mail just run a modified statement as the following:

Get-Mailbox -Server yourexchangeserver01 | Search-Mailbox -SearchQuery 'Subject:"New sales offer"' -deletecontent

or

Get-Mailbox -Server yourexchangeserver01 | Search-Mailbox -SearchQuery 'sales-department@mycompany.tld' -deletecontent

If that works you see some output as:

RunspaceId       : 024a0341-3daa-2b49-aac1-fed906816ed4
Identity         : adminenclave.local/FR/Agents/Joe Blocks
TargetMailbox    :
TargetPSTFile    :
Success          : True
TargetFolder     :
ResultItemsCount : 0
ResultItemsSize  : 0 B (0 bytes)

Leave your comments

Post comment as a guest

0

Comments

    • No comments found