Wednesday, October 15, 2014

Increasing Mailbox Deleted Items Retention in Exchange Online

Exchange Online has a default deleted items retention period for 14 days where the items are preserved in the dumpster and available for recovery, We may come across a business requirement where we need to increase this limit.



If this is an On premises Exchange Environment we can configure this value at Mailbox Database level Org wide and set all the users to UseDatabaseRetentionDefaults  when it comes to Exchange Online this is not possible and to address this requirement Microsoft has provided us a possible way to increase the retention period from 14 days to 30 days and higher than this is not possible by design.

To know more on this refer the below Microsoft knowledge Base article


Earlier this article was not updated to include the -UseDatabaseRetentionDefaults $False switch, When I worked on this requirement for my environment where few of my users were not set with the new retention limit though the new retention limit shell executed without errors for these users. Post working with Microsoft support team we were able to identify the above value is set to True on the affected users and caused this trouble which is quite unexpected and later used this switch to resolve the issue and successfully applied the new retention limit.

Utilize this below PowerShell script to get this set for all your users in Exchange Online and since this value is set by default when a new user is provisioned for Exchange Online you can utilize the other script to set a scheduled task that checks and sets this value everyday.

Script to set new retention limit

##Set new Retention Limit
$mailboxes = Get-Mailbox -Resultsize Unlimited | select Alias 
#Loop through each mailbox 
foreach ($mailbox in $mailboxes) { 
Set-Mailbox  -Identity $mailbox.Alias -SingleItemRecoveryEnabled $True -RetainDeletedItemsFor 30 -UseDatabaseRetentionDefaults $False
}

Script to Schedule to set New retention limit periodically

##Set new Retention Limit
$mailboxes = Get-Mailbox | where{$_.RetainDeletedItemsFor -eq 14} | select Alias 
#Loop through each mailbox 
foreach ($mailbox in $mailboxes) { 
Set-Mailbox  -Identity $mailbox.Alias -SingleItemRecoveryEnabled $True -RetainDeletedItemsFor 30 -UseDatabaseRetentionDefaults $False
}

I was happy to see this article updated to include this new switch as I suggested which makes things work well as desired and wanted to share this post so that you can utilize this updated article when you have a similar requirement in your environment in the mere future

Update:

Microsoft team did a recent enhancement to Exchange Online by extending the retention period of deleted items.

Review the Official blog post here : Extended email retention for deleted items in Office 365

No comments:

Post a comment