How to Delete All User Mailbox Contents Using a Retention Policy 

New Zealand | How to Delete All User Mailbox Contents Using a Retention Policy 

During a recent Tenant-To-Tenant migration project we were engaged on, a discrepancy in our data seeding dates resulted in a data copy to the destination occurring “too early.” Thankfully, this only impacted Exchange Online (EXO) and user mailboxes – which were not being used yet.  

As a result we needed to delete all contents of the impacted destination mailboxes. Sounds easy right? The mailboxes are not being used, so we can just delete them, and start from scratch… Right? Unfortunately, not! The specific requirement was “delete all contents without deleting the mailboxes”. No get out of jail free card here!  

One option was to use Search-Mailbox (ExchangePowerShell) | Microsoft Docs with a delete switch. But this required a dedicated device to run through a huge list which would need to be imported to PowerShell. What happened if the device went to sleep? If the internet dropped? It was just far too messy and clunky to be a guaranteed solution. The best option available was to implement a retention policy, which could be applied to the impacted users. Most importantly for this customer was we could also run reports and auditing on the progress which allowed them to keep their compliance and governance teams happy!

Solution

To implement this solution, you need to be an Exchange Administrator within M365 and comfortable with PowerShell. 

  • The first requirement is to create a new Retention Tag to target all mailbox contents for any items older than 1 day
    • New-RetentionPolicyTag -Name “Insentra – Delete All Mailbox Contents” -AgeLimitForRetention (New-TimeSpan -Days 1) -RetentionAction DeleteAndAllowRecovery -Type “All”
  • Create new retention policy with associated tags 
    • New-RetentionPolicy -Name “Insentra – Delete All Mailbox Contents” -RetentionPolicyTagLinks “Insentra – Delete All Mailbox Contents”
  • Assign the retention policy to the mailbox
    • Set-Mailbox -Identity “joe.bloggs@whatever.com” -RetentionPolicy “Insentra – Delete All Mailbox Contents”
  • Confirm the retention policy is assigned to the mailbox correctly
    • Get-Mailbox -Identity “joe.bloggs@whatever.com” | select RetentionPolicy
  • Start the retention policy processing the mailbox immediately
    • Start-ManagedFolderAssistant -Identity joe.blogg@whatever.com
  • Once you are happy with this, and if you want to apply this to users in bulk you can do this too. Create a CSV file with Mailbox as the column header, and list all the mailboxes
    • $Recipients = Import-Csv “C:\Temp\Users.csv”
    • Foreach ($Mailbox in $Recipients)
    • {
    • Set-Mailbox -Identity $Mailbox.Recipient -RetentionPolicy “Insentra – Delete All Mailbox Contents”}
    • }
  • Don’t forget to run the start the managed folder assistant processing too
    • $Recipients | ForEach-Object { Start-ManagedFolderAssistant -Identity $_ }  

This should help you clean up those impacted mailboxes and allow you to get out of a sticky situation.  

We recommend that you allow 2+ weeks to ensure the retention policy is processed and all the contents are fully deleted. Manually starting the Managed Folder Assistant will force the new retention policy to apply to the mailbox and adds the mailbox to a queue for processing. The underlying service which processes the messages and applies the retention policy settings (in this case, delete all contents) is Messaging Records Management (MRM), and unfortunately, it can take up to 7 days for the messages to be processed by MRM with the new retention settings. 

If you want to know any further information around Exchange and how Insentra can help, our Insentra Exchange Blogs may be exactly what you are looking for!  

Hopefully this has been informative and helpful! If you need any further clarification, or a no thrills chat, contact us at Insentra or read more of my Insentra Insights.

Join the Insentra Community with the Insentragram Newsletter

Hungry for more?

If you’re waiting for a sign, this is it.

We’re a certified amazing place to work, with an incredible team and fascinating projects – and we’re ready for you to join us! Go through our simple application process. Once you’re done, we will be in touch shortly!

New Zealand | How to Delete All User Mailbox Contents Using a Retention Policy 

Unleashing the power of Microsoft Copilot

This comprehensive guide provides everything you need to get your organisation ready for and successfully deploy Copilot.

Who is Insentra?

Imagine a business which exists to help IT Partners & Vendors grow and thrive.

Insentra is a 100% channel business. This means we provide a range of Advisory, Professional and Managed IT services exclusively for and through our Partners.

Our #PartnerObsessed business model achieves powerful results for our Partners and their Clients with our crew’s deep expertise and specialised knowledge.

We love what we do and are driven by a relentless determination to deliver exceptional service excellence.

New Zealand | How to Delete All User Mailbox Contents Using a Retention Policy 

Insentra ISO 27001:2013 Certification

SYDNEY, WEDNESDAY 20TH APRIL 2022 – We are proud to announce that Insentra has achieved the  ISO 27001 Certification.