We have a EXO mailbox, where E-Mails are collected for a special business process. This works fine, but the process-tool is not able to delete messages. So the mails are piling up. Around 100k E-Mails a month, until it's full.
I am tasked to automate a solution that deletes all the mailbox contents. This seems to be surprisingly difficult.
Search-Mailbox(worked fine, was deprectated, is now removed)*-ComplianceSearch*limit of 100 objects, purge action sometimes fails without errorsPurge-ComplianceSearchItems.ps1from Office365itpros does not work without filters, we just want to delete everythingRemove-MailboxandNew-Mailboxreattaches the same 'full' mailbox, because of the AADConnect UPN mapping- IMAP access (disabled because of security compliance)
- Hook OWA calls through JS (times out)
- PureView (never got it working somehow)
- "Empty folder" in OWA (authenticaton is a mess, the GUI seems to be limited somehow (folders are not fully empty), is slow and needs some user action)
How to "just" regularly delete all mailbox contents?
Maybe I have to fork Purge-ComplianceSearchItems.ps1 and customize it up to the point of automagic, but I am hoping for a good, maybe fast and (ideally) supported solution. If it's doable with pureview, I would appreciate guidance for setting this up (delete-everything-after-30d).
Update
Management has decided, that E-Mails from this mailx(es) must be purged on a given date (like "feb 2nd). The object shall not be removed by age (like 90d old). This scenario is not supported by retention tags.
How to delete content of a mailbox (by script)?