{"id":21475,"date":"2023-09-05T05:15:36","date_gmt":"2023-09-05T05:15:36","guid":{"rendered":"https:\/\/www.insentragroup.com\/nz\/?p=21475"},"modified":"2023-09-05T05:20:23","modified_gmt":"2023-09-05T05:20:23","slug":"how-to-delete-all-user-mailbox-contents-using-a-retention-policy","status":"publish","type":"post","link":"https:\/\/www.insentragroup.com\/nz\/insights\/geek-speak\/secure-workplace\/how-to-delete-all-user-mailbox-contents-using-a-retention-policy\/","title":{"rendered":"How to Delete All User Mailbox Contents Using a Retention Policy\u00a0"},"content":{"rendered":"\n<p>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 \u201ctoo early.\u201d Thankfully, this only impacted Exchange Online (EXO) and user mailboxes \u2013 which were not being used yet.&nbsp;&nbsp;<\/p>\n\n\n\n<p>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\u2026 Right? Unfortunately, not! The specific requirement was \u201cdelete all contents without deleting the mailboxes\u201d. No get out of jail free card here!&nbsp;&nbsp;<\/p>\n\n\n\n<p>One option was to use <a href=\"https:\/\/docs.microsoft.com\/en-us\/powershell\/module\/exchange\/search-mailbox?view=exchange-ps\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Search-Mailbox (ExchangePowerShell) | Microsoft Docs<\/a> 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!<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Solution<\/h2>\n\n\n\n<p>To implement this solution, you need to be an Exchange Administrator within M365 and comfortable with PowerShell.&nbsp;<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>The first requirement is to create a new Retention Tag to target all mailbox contents for any items older than 1 day\n<ul class=\"wp-block-list\">\n<li>New-RetentionPolicyTag -Name &#8220;Insentra &#8211; Delete All Mailbox Contents&#8221; -AgeLimitForRetention (New-TimeSpan -Days 1) -RetentionAction DeleteAndAllowRecovery -Type &#8220;All&#8221;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Create new retention policy with associated tags\u00a0\n<ul class=\"wp-block-list\">\n<li>New-RetentionPolicy -Name &#8220;Insentra &#8211; Delete All Mailbox Contents&#8221; -RetentionPolicyTagLinks &#8220;Insentra &#8211; Delete All Mailbox Contents&#8221;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Assign the retention policy to the mailbox\n<ul class=\"wp-block-list\">\n<li>Set-Mailbox -Identity &#8220;joe.bloggs@whatever.com&#8221; -RetentionPolicy &#8220;Insentra &#8211; Delete All Mailbox Contents&#8221;<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Confirm the retention policy is assigned to the mailbox correctly\n<ul class=\"wp-block-list\">\n<li>Get-Mailbox -Identity &#8220;joe.bloggs@whatever.com&#8221; | select RetentionPolicy<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Start the retention policy processing the mailbox immediately\n<ul class=\"wp-block-list\">\n<li>Start-ManagedFolderAssistant -Identity joe.blogg@whatever.com<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>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\n<ul class=\"wp-block-list\">\n<li>$Recipients = Import-Csv &#8220;C:\\Temp\\Users.csv&#8221;<\/li>\n\n\n\n<li>Foreach ($Mailbox in $Recipients)<\/li>\n\n\n\n<li>{<\/li>\n\n\n\n<li>Set-Mailbox -Identity $Mailbox.Recipient -RetentionPolicy &#8220;Insentra &#8211; Delete All Mailbox Contents&#8221;}<\/li>\n\n\n\n<li>}<\/li>\n<\/ul>\n<\/li>\n\n\n\n<li>Don\u2019t forget to run the start the managed folder assistant processing too\n<ul class=\"wp-block-list\">\n<li>$Recipients | ForEach-Object { Start-ManagedFolderAssistant -Identity $_ }&nbsp;&nbsp;<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<p>This should help you clean up those impacted mailboxes and allow you to get out of a sticky situation.&nbsp;&nbsp;<\/p>\n\n\n\n<p>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.&nbsp;<\/p>\n\n\n\n<p>If you want to know any further information around Exchange and how Insentra can help, our <a href=\"https:\/\/www.insentragroup.com\/nz?s=exchange\" target=\"_blank\" rel=\"noreferrer noopener\">Insentra Exchange Blogs<\/a> may be exactly what you are looking for!&nbsp;&nbsp;<\/p>\n\n\n\n<p>Hopefully this has been informative and helpful! If you need any further clarification, or a no thrills chat, <a href=\"https:\/\/www.insentragroup.com\/nz\/contact\/\" target=\"_blank\" rel=\"noreferrer noopener\">contact us<\/a> at Insentra or read more of my <a href=\"https:\/\/www.insentragroup.com\/nz\/insights\/insights-search-results\/?author=Dan%20Snape\" target=\"_blank\" rel=\"noreferrer noopener\">Insentra Insights<\/a>.<\/p>\n\n\n\n<style>\nbody .blog-body ul li ul li::marker {\n    color: #fff;\n}\nbody .blog-body ul li {\n    margin-bottom: 20px;\n}\n<\/style>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to delete mailbox contents using a retention policy in Exchange Online. Step-by-step guide for a clean solution. Keep compliance and governance intact! <\/p>\n","protected":false},"author":90,"featured_media":21485,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[20],"tags":[],"class_list":["post-21475","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-secure-workplace","entry"],"_links":{"self":[{"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/posts\/21475","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/users\/90"}],"replies":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/comments?post=21475"}],"version-history":[{"count":4,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/posts\/21475\/revisions"}],"predecessor-version":[{"id":21490,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/posts\/21475\/revisions\/21490"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/media\/21485"}],"wp:attachment":[{"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/media?parent=21475"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/categories?post=21475"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.insentragroup.com\/nz\/wp-json\/wp\/v2\/tags?post=21475"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}