May 04 2018 08:08 PM
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
May 05 2018 12:22 AM - edited May 05 2018 01:23 AM
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
May 05 2018 11:24 PM - edited May 05 2018 11:29 PM
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
May 05 2018 11:54 PM
SolutionHi,
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.
May 05 2018 11:54 PM
SolutionHi,
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.