Skip to content

Instantly share code, notes, and snippets.

@Grimthorr
Created January 13, 2015 16:09
Show Gist options
  • Save Grimthorr/d2ac246f204ee15503b6 to your computer and use it in GitHub Desktop.
Save Grimthorr/d2ac246f204ee15503b6 to your computer and use it in GitHub Desktop.
Generate a CSV report detailing the total size of and number of items in each Exchange user's Deleted Items folder.
cls
echo "Generating report for deleted items folders..."
echo "Please wait..."
$data = @()
foreach($mbx in Get-MailboxDatabase | Get-Mailbox) {
$dispname = $mbx.displayName
$data += Get-MailboxFolderStatistics $mbx.identity | where{$_.FolderType -eq "DeletedItems"} | Select-Object @{n="Username";e={$mbx.displayName}}, @{n="TotalSizeIncSubfolders(MB)";e={$_.FolderAndSubFolderSize.ToMb()}}, ItemsInFolderAndSubFolders
}
echo "Exporting report to C:\Temp\exchange-report-deleted-items.csv..."
$data | Sort-Object "TotalSizeIncSubfolders(MB)" –Descending | Export-Csv C:\Temp\exchange-report-deleted-items.csv
echo "All done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment