Forum Discussion
swapnil joshi
Feb 06, 2023Copper Contributor
Alert for recoverable deleted items
Hello All , In my org we have 2000 users ... We have retention policy in Data life cycle mgmt to retain all emails for ever. This results into exceeding threshold of 100GB of RDI (Recover de...
AlexMacedo
Mar 14, 2023Copper Contributor
Hi Swapnil,
You can have a weekly script checking each mailbox recoverable items size. Something like it:
$AllUsers = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Select-Object PrimarySMTPAddress
$a = 0
foreach ($Mailbox in $AllUsers)
{
Get-EXOMailboxFolderStatistics -Identity $Mailbox.PrimarySMTPAddress -FolderScope RecoverableItems | Where-Object {$_.FolderPath -eq "/Recoverable Items"} | Select-Object Identity,@{name="FolderAndSubFolderSize"; expression={[math]::Round(($_.FolderAndSubFolderSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}} | export-csv D:\All-Users-Folder-Size.csv -Append -NoTypeInformation
$a++
Write-host "Processing Mailbox" $Mailbox.PrimarySMTPAddress
}
#Saving output for sending the report via email
Import-csv D:\All-Users-Folder-Size.csv | Sort-Object {[int]$_.FolderAndSubFolderSize}, Identity -Descending | Export-csv D:\All-users-Sorted.csv -NoTypeInformation
Remove-Item -Path D:\All-Users-Folder-Size.csv
Send-MailMessage -From 'email address removed for privacy reasons' -To 'email address removed for privacy reasons'-Subject "Recoverable Items Report' -Body "Recoverable Items Report" -Attachments D:\All-users-Sorted.csv -Priority High -DeliveryNotificationOption OnSuccess, OnFailure -SmtpServer 'smtp.contoso.com'
You can have a weekly script checking each mailbox recoverable items size. Something like it:
$AllUsers = Get-Mailbox -RecipientTypeDetails UserMailbox -ResultSize Unlimited | Select-Object PrimarySMTPAddress
$a = 0
foreach ($Mailbox in $AllUsers)
{
Get-EXOMailboxFolderStatistics -Identity $Mailbox.PrimarySMTPAddress -FolderScope RecoverableItems | Where-Object {$_.FolderPath -eq "/Recoverable Items"} | Select-Object Identity,@{name="FolderAndSubFolderSize"; expression={[math]::Round(($_.FolderAndSubFolderSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}} | export-csv D:\All-Users-Folder-Size.csv -Append -NoTypeInformation
$a++
Write-host "Processing Mailbox" $Mailbox.PrimarySMTPAddress
}
#Saving output for sending the report via email
Import-csv D:\All-Users-Folder-Size.csv | Sort-Object {[int]$_.FolderAndSubFolderSize}, Identity -Descending | Export-csv D:\All-users-Sorted.csv -NoTypeInformation
Remove-Item -Path D:\All-Users-Folder-Size.csv
Send-MailMessage -From 'email address removed for privacy reasons' -To 'email address removed for privacy reasons'-Subject "Recoverable Items Report' -Body "Recoverable Items Report" -Attachments D:\All-users-Sorted.csv -Priority High -DeliveryNotificationOption OnSuccess, OnFailure -SmtpServer 'smtp.contoso.com'