{"id":51,"date":"2008-05-22T13:20:15","date_gmt":"2008-05-22T18:20:15","guid":{"rendered":"http:\/\/it.thelibrarie.com\/weblog\/?p=51"},"modified":"2011-05-23T13:58:10","modified_gmt":"2011-05-23T18:58:10","slug":"exchange-2007-mailbox-statistics","status":"publish","type":"post","link":"https:\/\/it.thelibrarie.com\/weblog\/2008\/05\/exchange-2007-mailbox-statistics\/","title":{"rendered":"Exchange 2007 Mailbox Statistics"},"content":{"rendered":"<p>If only Microsoft would realize that it&#8217;s pretty easy to add a single column known as &#8220;size of mailbox&#8221; when searching through the GUI exchange management tool.  Instead, we have to open up the Command prompt tool.  Big deal.<\/p>\n<p>Here&#8217;s the quick and easy way to list the name of the mailbox, size of said mailbox, and number of emails:<br \/>\n<code>Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=\"TotalItemSize(KB)\";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount<\/code><\/p>\n<p>And apparently you can get it to email you if you write a script as follows:<br \/>\n<code>###Send mailbox statistics script<br \/>\n###First, the administrator must change the mail message values in this section<br \/>\n$FromAddress = \"MailboxReport@ngh.net\"<br \/>\n$ToAddress = \"administrator@ngh.net\"<br \/>\n$MessageSubject = \"Mailbox Size Report\"<br \/>\n$MessageBody = \"Attached is the current list of mailbox sizes.\"<br \/>\n$SendingServer = \"e2k7.ngh.net\"<br \/>\n###Now get the stats and store in a text file<br \/>\nGet-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=\"TotalItemSize(KB)\";expression={$_.TotalItemSize.Value.ToKB()}}, ItemCount > mailboxes.txt<br \/>\n###Create the mail message and add the statistics text file as an attachment<br \/>\n$SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress,<br \/>\n$MessageSubject, $MessageBody<br \/>\n$Attachment = New-Object Net.Mail.Attachment(\".\/mailboxes.txt\")<br \/>\n$SMTPMessage.Attachments.Add($Attachment)<br \/>\n###Send the message<br \/>\n$SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer<br \/>\n$SMTPClient.Send($SMTPMessage)<br \/>\n<\/code><\/p>\n<p>But I couldn&#8217;t get it to actually attach the txt document.<\/p>\n<p>EDIT!!!<\/p>\n<p>11.11.2008<\/p>\n<p>I got it to work &#8211; the problem was with a couple issues we had.<\/p>\n<p>1.) In the Windows PowerShell, you must <code>Set-ExecutionPolicy Unrestricted<\/code><br \/>\n2.) I wrote a bat file to open this once a week:<br \/>\n<code>C:\\WINDOWS\\system32\\WindowsPowerShell\\v1.0\\PowerShell.exe -PSConsoleFile \"C:\\Program Files\\Microsoft\\Exchange Server\\bin\\exshell.psc1\" -command \". 'C:\\sendstats.ps1'\"<\/code><br \/>\n3.) I wrote a ps1 file to run the actual commands (see above for the code)<br \/>\n4.) If you get an error, see if the following command helps:<br \/>\n<code>Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin<\/code><br \/>\n5.) MAKE SURE the get-mailboxstatistics is all on one single line &#8211; I can&#8217;t tell you how much word-wrap in notepad screwed me out of 20 minutes of time.<\/p>\n<p>***EDIT 05.23.2011***<br \/>\nSo Exchange 2010 screwed me a little bit on this &#8211; it requires another flag:<br \/>\n<code>Get-MailboxStatistics -server SERVERNAME | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label=\"TotalItemSize(KB)\";expression={$_.TotalItemSize.Value.ToKB()}},ItemCount<\/code><\/p>\n<p>You can use -Identity MAILBOXORUSERNAME, -Database DATABASEHERE, or -Server SERVERNAMEHERE.  I chose server as it&#8217;s exactly what I needed.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If only Microsoft would realize that it&#8217;s pretty easy to add a single column known as &#8220;size of mailbox&#8221; when searching through the GUI exchange management tool. Instead, we have to open up the Command prompt tool. Big deal. Here&#8217;s the quick and easy way to list the name of the mailbox, size of said &hellip; <a href=\"https:\/\/it.thelibrarie.com\/weblog\/2008\/05\/exchange-2007-mailbox-statistics\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Exchange 2007 Mailbox Statistics<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-51","post","type-post","status-publish","format-standard","hentry","category-microsoft"],"_links":{"self":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/51","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/comments?post=51"}],"version-history":[{"count":4,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/51\/revisions"}],"predecessor-version":[{"id":179,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/posts\/51\/revisions\/179"}],"wp:attachment":[{"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/media?parent=51"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/categories?post=51"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/it.thelibrarie.com\/weblog\/wp-json\/wp\/v2\/tags?post=51"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}