How to forcibly clean up deleted messages in the database, bypassing the policy of storing deleted messages in 14 days?

Pavel 206 Reputation points
2021-04-07T11:56:27.323+00:00

Good day!

In the settings of user mailboxes in Exchange 2013 there is an option: "Keep deleted items for n days." By default, everyone has 14.

The user cleared his mailbox, and I need this deleted data to be immediately cleaned up on the database and free space.

Are there any commands for this?

I have set the storage option "Keep deleted items..."for this user to 0 days. But the place in the database was not vacated.

Question: the set value of 0 days will be valid only for newly deleted messages, and the previously deleted ones will still be kept for 14 days?

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,335 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Andy David - MVP 141.1K Reputation points MVP
    2021-04-07T12:46:49.88+00:00

    Make sure the mailbox is not using the database defaults:
    Set-mailbox <user> -UseDatabaseRetentionDefaults:$false

    and it should work overnight

    If not then you can do this:

    Set to 0 on the database and UseDatabaseRetentionDefaults to $true on the mailbox and it should be cleared out overnight. Not really a good way to force it however

    so:

    set-mailboxdatabase <DB> -DeletedItemRetention 0 -RetainDeletedItemsUntilBackup:$False  
    

    https://learn.microsoft.com/en-us/powershell/module/exchange/set-mailboxdatabase?view=exchange-ps

    and for the mailbox:

    set-mailbox <user> -UseDatabaseRetentionDefaults:$true  
    

    https://learn.microsoft.com/en-us/powershell/module/exchange/set-mailbox?view=exchange-ps

    NOTE: This will clear it for ALL the mailboxes on that database, so ensure of you DO NOT want to do this for all that the other mailboxes are set:

    set-mailbox <user> -UseDatabaseRetentionDefaults:$false

    0 comments No comments

  2. Eric Yin-MSFT 4,386 Reputation points
    2021-04-08T03:03:41.443+00:00

    Question: the set value of 0 days will be valid only for newly deleted messages, and the previously deleted ones will still be kept for 14 days?

    • I tried to set the value to 0, using MFC MAPI to compare the properties of a message that should be kept in deletions for 14 days and 0 days, but unfortunately there's not any values that work like PR_Retention_Date, only last modification time and message creation time:
      85535-3.png

    So I back to official doc and found something might related: Clean up or delete items from the Recoverable Items folder
    When he changes the settings, the Microsoft Exchange Mailbox Assistants service need to be stopped, which might mean if you don't stop the service, those settings changes at once.

    All above is just my guess, hope it helps.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.