SOLVED

Delete items from Recoverable Items folder

Brass Contributor

Hi experts, i want to delete items from recoverable items folder, i am using exchange 2016. i am also member of discovery mgmt role group.

Get-MailboxFolderStatistics -Identity user -FolderScope RecoverableItems | Format-Table Name,FolderAndSubfolderSize,ItemsInFolderAndSubfolders -Auto

Name              FolderAndSubfolderSize          ItemsInFolderAndSubfolders
----              ----------------------          --------------------------
Recoverable Items 100 GB                              496523
Audits            45.40 MB                            20088
Calendar Logging  0 B (0 bytes)                        0
Deletions         4.385 GB                            24513
Purges            65.77 GB                            420333
Versions          27.91 GB                            42889

Set-Mailbox -Identity "myuser@mydomain.com" -SingleItemRecoveryEnabled $true -RetainDeletedItemsFor 02
I tried below  command both did not work

[PS] C:\Windows\system32>Search-Mailbox -identity myuser -SearchDumpsterOnly -DeleteContent

Search-Mailbox : The term 'Search-Mailbox' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try
again.
At line:1 char:1
+ Search-Mailbox -identity myuser -SearchDumpsterOnly -DeleteContent
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Search-Mailbox:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException


i want to try the below command but what does size>0 mean.
please provide me syntax
Search-Mailbox <username> -SearchQuery size>0 -SearchDumpsterOnly -DeleteContent

 

3 Replies

is it that search mailbox doesnot work for exchange online, i have rights to mailbox search and importexport

[PS] C:\Windows\system32> Search-Mailbox myuser -SearchQuery size>0 -SearchDumpsterOnly -DeleteContent
Search-Mailbox : The term 'Search-Mailbox' is not recognized as the name of a cmdlet, function, script file, oroperable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:2
+ Search-Mailbox myuser -SearchQuery size>0 -SearchDumpsterOnly -DeleteContent
+ ~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Search-Mailbox:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

Hi,

 

To use the DeleteContent switch with Search-Mailbox cmdlet,  you have to be assigned the Mailbox Import Export management role. By default, this role isn't assigned to any role group. Typically, you assign a role to a built-in or custom role group. or you can assign a role to a user, or a universal security group. The below example add the role to the Organization Management role group:

 

New-ManagementRoleAssignment -Name "Import_Export_Organization_Management" -SecurityGroup "Organization Management" -Role "Mailbox Import Export"

 

Note: You have to create a new Exchange Online PowerShell session to get new role permissions. 
 

You can read this post for more info: How to: Add Mailbox Import Export Role in Office 365 using PowerShell

 

best response confirmed by Rising Flight (Brass Contributor)
Solution

Hi,

To use the DeleteContent switch with Search-Mailbox cmdlet, you have to be assigned the Mailbox Import Export management role. By default, this role isn't assigned to any role group. Typically, you assign a role to a built-in role group, or you can assign a role to a user, or a universal security group. The below example add the role to the Organization Management role group:

New-ManagementRoleAssignment -Name "Import_Export_Organization_Management" -SecurityGroup "Organization Management" -Role "Mailbox Import Export"

Note: You have to create a new Exchange Online PowerShell session to get new role permissions.

1 best response

Accepted Solutions
best response confirmed by Rising Flight (Brass Contributor)
Solution

Hi,

To use the DeleteContent switch with Search-Mailbox cmdlet, you have to be assigned the Mailbox Import Export management role. By default, this role isn't assigned to any role group. Typically, you assign a role to a built-in role group, or you can assign a role to a user, or a universal security group. The below example add the role to the Organization Management role group:

New-ManagementRoleAssignment -Name "Import_Export_Organization_Management" -SecurityGroup "Organization Management" -Role "Mailbox Import Export"

Note: You have to create a new Exchange Online PowerShell session to get new role permissions.

View solution in original post