Link to home
Start Free TrialLog in
Avatar of CiscoAzn
CiscoAznFlag for United States of America

asked on

Powershell script to check the TotalDeletedItemSize

When running the command "Get-MailboxStatistics <username> | FL" there is an output for "TotalDeletedItemSize". Is there a way to have a schedule script to run that would show all users in an OU that has over 90GB for the TotalDeletedItemSize? Just need a weekly report of this.
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

This will be my code

Add-pssnapin Microsoft.Exchange.Management.PowerShell.E2010
$ReportNameAndPath="$env:userprofile\desktop\report.html"
$css3="<style>td,th{border:1px solid #ddd;padding:8px}th{padding-bottom:12px;text-align:left;background-color:#4caf50;color:#fff}</style>"
$OUName = "Accounting"
$OUData = Get-OrganizationalUnit $OUName
Get-mailbox -OrganizationalUnit $($OUData.DistinguishedName) -resultsize unlimited | Get-MailboxStatistics | select Displayname,ItemCount,TotalDeletedItemsize | sort-object TotalDeletedItemSize -Descending | ConvertTo-Html -Head $css3 | Out-File $ReportNameAndPath

Open in new window


Output
User generated image
Avatar of CiscoAzn

ASKER

Thanks Jose but these mailboxes are on O365. What's the code to call it in the beginning? Under the $OUName would that be the DN of the OU?
Clarify in your question that is for Office 365, that's not specified anywhere :P
TotalDeletedSize on 90Gb ? why?
That would be an almost 100Gb mailbox that has 90Gb deleted, it's a hard condition to hit.
ASKER CERTIFIED SOLUTION
Avatar of J0rtIT
J0rtIT
Flag of Venezuela, Bolivarian Republic of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Jose!
Np! :)