daknetworks.com

You are here: Blog Delete Emails Across Entire Exchange 2013

Delete Emails Across Entire Exchange 2013

1-First create a folder in your Outlook called: SearchAndDeleteLog
(As a root folder. Not an INBOX subfolder)

2-Now in Exchange-Mangement-Shell EMS) search for the messages with the SENDER, DATE and SUBJECT and put the results in your own mailbox:

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {from: This e-mail address is being protected from spambots. You need JavaScript enabled to view it AND Received:"03/17/2018" AND Subject:"Your bank statement"} -TargetMailbox "my.account" -TargetFolder "SearchAndDeleteLog" -LogOnly -LogLevel Full

Or for a date-range:

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {from: This e-mail address is being protected from spambots. You need JavaScript enabled to view it AND Received:"03/16/2018 10:00..03/17/2018 13:00" AND Subject:"Your bank statement"} -TargetMailbox "my.account" -TargetFolder "SearchAndDeleteLog" -LogOnly -LogLevel Full

Or for a domain name:

Get-Mailbox -ResultSize unlimited | search-mailbox -SearchQuery "@domain.tld" -TargetMailbox "my.account" -TargetFolder "SearchAndDeleteLog" -LogOnly -LogLevel Full

3-Look in your Outlook and verify the results.

4-After you are sure of the results, run the command to delete:

Get-Mailbox -ResultSize unlimited | Search-Mailbox -SearchQuery {from: This e-mail address is being protected from spambots. You need JavaScript enabled to view it AND Received:"03/17/2018"} -DeleteContent

If you need to copy the messages from a specific mailbox:

Get-Mailbox foo.user | Search-Mailbox -SearchQuery {from: This e-mail address is being protected from spambots. You need JavaScript enabled to view it AND Received:"03/01/2018"} -TargetMailbox "my.account" -TargetFolder "SearchAndDeleteLog"

 

Contact Dak Networks

We are not taking on new clients at this time.