Motivation: Making the Systems Engineers life easier.

Clean up or delete items from the Recoverable Items folder

Microsoft Exchange

Clean up or delete items from the Recoverable Items folder

Recently I received a request from a user for permanently deleting the items from “Recover Delete Items” folder.

Multiple scripts are available on Microsoft Documentation site.

I had the below command but I received an error:

[PS] C:\>Search-Mailbox -Identity “user.name@domain.com” -SearchDumpsterOnly -TargetMailbox “Discovery Search Mailbox” -TargetFolder “UserName-RecoverableItems” -DeleteContent

WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the Exchange Administration Center.
The operation couldn’t be performed because object ‘user.name@domain.com’ couldn’t be found on
‘dcname.contoso.com’.
+ CategoryInfo : InvalidArgument: (0:Int32) [Search-Mailbox], ManagementObjectNotFoundException
+ FullyQualifiedErrorId : [Server=Exchangename,RequestId=bdf793dc-66b7-48d5-a813-114e97cfddf1,TimeStamp=3/23/2021 5:56:10 AM] [FailureCategory=Cmdlet-ManagementObjectNotFoundException] 934688C2,Microsoft.Exchange.Management.Tasks.SearchMailbox
+ PSComputerName : Exchangename.contoso.com

In the Active Directory Forest, there are multiple domains running under single forest.

In order to see find the user id running on the another domain in the single forest we need to run the following command:

[PS] C:\>Set-AdServerSettings -ViewEntireForest $true -SetPreferredDomainControllers dc.domain.com

After running the above command  I could successfully execute the command to cleanup my “Recover Deleted Items: Folder:

[PS] C:\>Search-Mailbox -Identity “user.name@domain.com” -SearchDumpsterOnly -TargetMailbox “Discovery Search Mailbox” -TargetFolder “UserName-RecoverableItems” -DeleteContent -DomainController dc.domain.com
WARNING: The Search-Mailbox cmdlet returns up to 10000 results per mailbox if a search query is specified. To return more than 10000 results, use the New-MailboxSearch cmdlet or the In-Place eDiscovery & Hold console in the Exchange Administration Center.

Confirm
Deleting content from mailboxes user.name@domain.com
[Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is “Y”): Y
[PS] C:\>

Remember that once the above command is run it will take a long time to complete.

 

Leave your thought here

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Topics