I can’t seem to find a way to get a detailed listing of exchange mailboxes and their size, # of emails etc. I would like to be able to generate a report not just of the top 5 or so but of all mailboxes to encourage managing the size of mailboxes
1 Spice up
I have a task run this every week to send a mailbox size report to me. Pretty much an automated get-mailboxstatistics call.
$smtpServer = "SERVER"
$mailTo = ("MyAddress@myDomain.com")
$mailFrom = "logs@myDomain.com"
$a = "<style>"
#$a = $a + "BODY{font-family: Arial, Arial, Helvetica, sans-serif;font-size:10;font-color: #000000}"
$a = $a + "BODY{font-family: Arial;font-color: #000000}"
$a = $a + "TABLE{border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}"
$a = $a + "TH{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color: #888888}"
$a = $a + "TD{border-width: 1px;padding: 0px;border-style: solid;border-color: black;background-color: #FFFFFF}"
#get-mailbox -server $server | get-mailboxstatistics | Sort-Object TotalItemSize -descending | Select-Object DisplayName, @{Label="Mailbox Size (MB)";Expression={$_.TotalItemSize.Value.ToMB()}}, @{Label="Dumpster Size (MB)";Expression={$_.TotalDeletedItemSize.Value.ToMB()}}, ItemCount, Database | ConvertTo-HTML -head $a | Out-File D:\Scripts\Test.htm
$server = $env:computername
$body = get-mailbox -server $server | get-mailboxstatistics | Sort-Object TotalItemSize -descending | Select-Object DisplayName, @{Label="Mailbox Size (MB)";Expression={$_.TotalItemSize.Value.ToMB()}}, @{Label="Dumpster Size (MB)";Expression={$_.TotalDeletedItemSize.Value.ToMB()}}, ItemCount, Database | ConvertTo-HTML -head $a
Send-MailMessage -To $mailTo -From $mailFrom -Subject "Exchange MailBox Size Report" -SmtpServer $smtpServer -Body ($body| Out-String) -BodyAsHtml
Thank you this was very helpful