Jump to content
EduGeek EdSec 2026 is Go! 27th Oct in Derby! Join us for a day of EdTech security focused talks, networking, and an evening social ×

Recommended Posts

Posted (edited)

You will need to change the SearchQuery as below. Be aware, -DeleteContent is a pretty disruptive command and it may be best to test the code by modifying it to log the output first.

 

Search-Mailbox -identity -SearchQuery 'Sent<="2012-12-31" AND kind:email' -DeleteContent

 

 

This code searches the mailbox for messages that cmatch the query and logs the result in the SearchAndDeleteLog folder in the administrator's mailbox. Messages aren't copied to the target mailbox.

 

Search-Mailbox -Identity "mailboxname" -SearchQuery 'Sent<="2012-12-31" AND kind:email' -TargetMailbox "administrator" -TargetFolder "SearchAndDeleteLog" -LogOnly -LogLevel Full

Edited by djm968
  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...