Forum Discussion

Rising Flight's avatar
Rising Flight
Brass Contributor
May 05, 2018
Solved

Delete items from Recoverable Items folder

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

 

  • 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.

3 Replies

  • Kevin_Morgan's avatar
    Kevin_Morgan
    Iron Contributor

    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.

  • Kevin_Morgan's avatar
    Kevin_Morgan
    Iron Contributor

    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: https://www.morgantechspace.com/2018/04/how-to-add-mailbox-import-export-role-in-office-365-powershell.html

     

  • Rising Flight's avatar
    Rising Flight
    Brass Contributor

    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

Resources