Exchange 2007 : Purge Outbox Script
I recently cam across an issue where users email was getting 'stuck' in their Outbox, despite being sent to the intended recipient. Some users had approx 95% of the mailbox Send limit in stuck email, so this problem was affecting their ability to work.$data = @()
foreach($mbx in Get-Mailbox -ResultSize unlimited) { $data += Get-MailboxFolderStatistics $mbx.identity -FolderScope 'Outbox' | select @{n="DisplayName";e={$mbx.DisplayName}},FolderPath,ItemsInFolder,@{n="FolderSize(MB)";e={$_.folderSize.toMB()}}}
$data | sort-object "FolderSize(MB)" –Descending | export-csv c:\Outbox_sizes.csv
Once I had identified the severity of the issue I wrote the following power shell script to purge all user Outboxes, exporting the to a PST file in case of any repercussion, note you will have to create the intended export folder prior to running this scrip. As before, copy the following command into a ' .ps1' file and execute from the Exchange Shell:
foreach($mbx in Get-Mailbox -ResultSize unlimited){ Export-Mailbox -Identity $mbx.identity -IncludeFolders "\Outbox" -PSTFolderPath "C:\OutboxExport\" -DeleteContent -BadItemLimit 1000 -confirm:$false }