How to purge emails

this only apply for exchange on-prem, can be exchange 2010, 2013 or 2016

Search-Mailbox tony@tonyexchange.com -SearchQuery ‘from:”brannon@companyx.net” subject:”December Unpaid Invoice” sent:10/11/2017’ -TargetMailbox “Exch Admin” -TargetFolder “Purged01″ -LogLevel full

The switches –LogLevel full mean that the result of the search will be copied to the folder Purged01 into the mailbox Exch Admin.

If we don’t want to copy put the switches -LogLevel full –logonly and the end of the above command.

Example:

Search-Mailbox tony@tonyexchange.com -SearchQuery ‘from:”brannon@companyx.net” subject:”December Unpaid Invoice” sent:10/11/2017’ -TargetMailbox “Exch Admin” -TargetFolder “Purged01″ -LogLevel full –logonly

If we want to delete the content just put the switch –DeleteContent.

Example:

Search-Mailbox tony@tonyexchange.com -SearchQuery ‘from:”brannon@companyx.net” subject:”December Unpaid Invoice” sent:10/11/2017’ –DeleteContent.

Leave a comment