Forum Discussion

venkatkirankona's avatar
venkatkirankona
Brass Contributor
Dec 10, 2022
Solved

How to clear the Discovery Holds folder

To find whether this discovery holds folder is completely full, use the below-mentioned command. 

 

Step 1: Connect-ExchangeOnline

 

and then,

 

Step 2: Get-MailboxFolderStatistics -Identity user | select name,foldersize

 

 

Note: This DiscoveryHolds folder is having a limit of 100 GB. If it is full, we will get issues like "Unable to clear deleted items folder", "deleted items are getting auto-restored" etc.,

 

One of the reasons for this folder is full: If Organization Hold is turned on(All Exchange mailboxes are selected in Compliance Retention Policy) or the Individual ID is selected on Compliance Retention Policy. 

 

Solution

 

Please try the below-mentioned steps to overcome this issue. 

 

Step 1: Exclude the DiscoveryHolds full ID in the Compliance Retention policy or run the below-mentioned commands in PowerShell. 

 

Connect-IPPSSession

 

and then,

 

Set-RetentionCompliancePolicy -Identity "Compliance Retention Policy Name" -AddExchangeLocationException user

 

for multiple users, 

 

Set-RetentionCompliancePolicy -Identity "Compliance Retention Policy Name" -AddExchangeLocationException user1, user2, user3

 

Now on PowerShell, 

 

Connect-ExchangeOnline

 

and then, 

 

Set-Mailbox -Identity user -RetainDeletedItemsFor 0

 

and then run the below-mentioned command two times. 

 

Start-Managedfolderassistant -Identity user

Start-Managedfolderassistant -Identity user

 

After 2-3 minutes, run the below-mentioned commands. 

 

Get-Mailbox "user" | FL DelayHoldApplied,DelayReleaseHoldApplied

 

If the output is received as true for any above-mentioned holds, then run the below-mentioned commands. 

 

Set-Mailbox user -RemoveDelayHoldApplied
Set-Mailbox user -RemoveDelayReleaseHoldApplied

 

and then run the below-mentioned command two times. 

 

Start-Managedfolderassistant -Identity user

Start-Managedfolderassistant -Identity user

 

After 2-3 minutes, this DiscoveryHolds folder will become zero as per the below-mentioned screenshot. 

 

 

This process helped me a lot. If you have any doubts/concerns/suggestions about this post, please comment below. 

 

Best Regards,

Venkat Kiran Kona. 

  • Great post, thank you. This helped me when both RecoveryItems and DiscoveryHolds were full. We had a lot of retention policies, so using this command excluded them from all polices:

     

     

    Get-RetentionCompliancePolicy | foreach {Set-RetentionCompliancePolicy -identity $_.name -AddExchangeLocationException <user>}

     

     

    Also, it can take a lot more than a few minutes if the mailbox has a lot of items (in my case, 100GB). It's going very slow for me, maybe 1GB every hour or two.

  • Kundrak96's avatar
    Kundrak96
    Copper Contributor

    Amazing! This solved my problem with an email account that's impossible to delete items from the "Recoverable Items" folder. I have invested a lot of hours trying to solve the problem with no results.
    This saved me!

    Finally, I used a script that made it easier!

  • JoseOrne's avatar
    JoseOrne
    Copper Contributor
    Thank you so much for this info. This worked for the issue we were having, my question would be how do I undo the changes to the affected mailbox? I'm talking about the settings like Set-RetentionCompliancePolicy -Identity "Compliance Retention Policy Name" -AddExchangeLocationException user and the -retaindeleteditemsfor settings.
    • TheHundTech's avatar
      TheHundTech
      Copper Contributor

      The Set-RetentionCompliancePolicy command has a property called -RemoveExchangeLocationException, it will basically be:
      Set-RetentionCompliancePolicy -Identity "Compliance Retention Policy Name" -RemoveExchangeLocationException user

    • venkatkirankona's avatar
      venkatkirankona
      Brass Contributor
      We can remove the same excluded ones by using commands else by going to the compliance portal to the "retention policy".
  • EPWidjaya's avatar
    EPWidjaya
    Copper Contributor

    venkatkirankona 

     

    Hi this is something I've been looking for.

    can you help me on this? i tried what you did but it doesnt work for me.

     

    Set-Mailbox -Identity xyz -RetainDeletedItemsFor 0
    Start-Managedfolderassistant -Identity xyz
    Start-Managedfolderassistant -Identity xyz
    Get-Mailbox xyz | FL DelayHoldApplied,DelayReleaseHoldApplied

    >>DelayHoldApplied : False
    >>DelayReleaseHoldApplied : False


    Get-MailboxFolderStatistics -Identity xyz | select name,foldersize
    Get-RetentionCompliancePolicy | foreach {Set-RetentionCompliancePolicy -identity $_.name -AddExchangeLocationException xyz}

    Start-Managedfolderassistant -Identity xyz
    Start-Managedfolderassistant -Identity xyz


    Get-MailboxFolderStatistics -Identity xyz | select name,foldersize
    Start-Managedfolderassistant -Identity xyz
    Start-Managedfolderassistant -Identity "email address removed for privacy reasons"

     

    Get-MailboxFolderStatistics -Identity xyz | select name,foldersize

     

    • venkatkirankona's avatar
      venkatkirankona
      Brass Contributor
      What is the error?

      Before running these commands, you need to exclude the IDs on compliance retention policy.
  • koakd540's avatar
    koakd540
    Copper Contributor

    Great post, thank you. This helped me when both RecoveryItems and DiscoveryHolds were full. We had a lot of retention policies, so using this command excluded them from all polices:

     

     

    Get-RetentionCompliancePolicy | foreach {Set-RetentionCompliancePolicy -identity $_.name -AddExchangeLocationException <user>}

     

     

    Also, it can take a lot more than a few minutes if the mailbox has a lot of items (in my case, 100GB). It's going very slow for me, maybe 1GB every hour or two.

    • venkatkirankona's avatar
      venkatkirankona
      Brass Contributor
      Try to run this "start-managedfolder" command 2 times at once and repeat every 5 mins.

      Thanks for the response btw and good to see that this is helpful.
      • koakd540's avatar
        koakd540
        Copper Contributor

        venkatkirankona 

        This is working perfectly! I came in this morning and the deletions had stalled, tried your method of running it twice every 5 minutes and it's dropped from 99GB to 58GB in about an hour. Here's a snippet to do this every 5 mins automatically, and report the size of the folders:

        while ($true) {
            Start-ManagedFolderAssistant -Identity <email address removed for privacy reasons>
            Start-ManagedFolderAssistant -Identity <email address removed for privacy reasons>
            sleep 300
            Get-MailboxFolderStatistics <email address removed for privacy reasons> -FolderScope RecoverableItems | Ft Name,FolderAndSubfolderSize
            }

         

Resources