2

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 errors
  • Purge-ComplianceSearchItems.ps1 from Office365itpros does not work without filters, we just want to delete everything
  • Remove-Mailbox and New-Mailbox reattaches 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)?

bjoster
  • 5,241

1 Answers1

0

A few ways forward:

Check what the purview policies look like on the commandline, they may be different than what the GUI shows and maybe that is why it isn't working

Use the new Search-Mailbox replacement cmdlets: https://answers.microsoft.com/en-us/msoffice/forum/all/if-search-mailbox-is-now-deprecated-how-do-i/d686ff98-4f0e-4fae-af30-c7318bce9b77

Fork Purge-ComplianceSearchItems.ps1, seems like it wouldn't be too bad

Ask security team to loosen their grip(enable IMAP for the mailbox and set up CAP allowing access only from your on-prem servers) and load the mailbox into a secure server in your network via Outlook, write a custom script to interact with the COMObject from Outlook to delete what you need to on a schedule. https://learn.microsoft.com/en-us/archive/msdn-magazine/2013/march/powershell-managing-an-outlook-mailbox-with-powershell

Quinn Favo
  • 21
  • 1
  • 7