As an Exchange Administrator, you can generate a mailbox folder size report for any user. It is extremely helpful if the USER doesn’t know how his/her mailbox is reaching size limit & which FOLDER has most emails.
Well here is the one-liner PowerShell script (Note: Replace username@company.com with user’s email address):
Get-MailboxFolderStatistics username@company.com | Select-Object FolderPath,@{Name="SubFoldersize";Expression={$r=$_.FolderAndSubfolderSize; [int] $a = ($r.Substring($r.IndexOf("(")+1,($r.Length - 2 - $r.IndexOf("("))) -replace " bytes","" -replace ",","") ; $a } } | Sort-Object SubFolderSize -Descending | Select-Object FolderPath,@{Name="Folder-and-Subfolder-Size";Expression={[String] $_.SubFolderSize + " MB"}}
The sample output shows this:
FolderPath Folder-and-Subfolder-Size ---------- ------------------------- /Scheduled Reports 1625 MB /incoming Unapproved emails 1165 MB /Audits 907 MB /Compliants 562 MB /Policy Violation Compliants 551 MB /Deleted Items 482 MB /Server Activity Summary 449 MB /VM Approval Requests 236 MB /Approved Requests 71 MB /New Accounts 61 MB /Profile Review 57 MB /Authorizations 35 MB /Rejected Content 11 MB /Sent Items 8 MB /PersonMetadata 6 MB /Contacts 3 MB /Contacts/Recipient Cache 3 MB /Calendar 0 MB /Drafts 0 MB /Quick Step Settings 0 MB
You can export this to CSV file by adding “| Export-CSV -Path .\MBFolderSizeReport.csv -NoTypeInformation”. If it helped you, leave me a “Thanks” in the comments.
Hey Anand, I tried running your script and got the below error. Something I’m doing wrong? Thanks for taking the time to share.
At line:1 char:399
+ … th,@{Name=”Folder-and-Subfolder-Size”;Expression={[string]int + ” MB” …
+ ~~~
Unexpected token ‘int’ in expression or statement.
+ CategoryInfo : ParserError: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : UnexpectedToken
Jerry, I fixed the script. It should work now.
And thanks for noticing the embarrasing mistake.