{"id":1586,"date":"2015-07-31T17:24:49","date_gmt":"2015-07-31T17:24:49","guid":{"rendered":"http:\/\/microsoftgeek.com\/?p=1586"},"modified":"2015-07-31T17:26:43","modified_gmt":"2015-07-31T17:26:43","slug":"using-powershell-to-get-mailbox-database-size-and-available-new-mailbox-space","status":"publish","type":"post","link":"https:\/\/microsoftgeek.com\/?p=1586","title":{"rendered":"Using PowerShell to Get Mailbox Database Size and Available New Mailbox Space"},"content":{"rendered":"<p>As your\u00a0Exchange Server\u00a0mailbox databases grow you\u2019re eventually going to be interested in finding out two things \u2013 how large the database file is, and how much available new mailbox space is in the database.<\/p>\n<p>\u201cAvailable new mailbox space\u201d is sometimes referred to as \u201cwhite space\u201d, although the folks at Microsoft will tell you that is not the correct term for it. I\u2019ll try to stick to the correct terminology in this article.<\/p>\n<p>If you\u2019re not sure what that \u201cavailable new mailbox space\u201d means, consider this example. Let\u2019s say you\u2019ve got a 100Gb mailbox database, with 0Gb of available new mailbox space. If you move a 5Gb mailbox to that database you can expect the database file to grow by approximately 5Gb. If on the other hand you\u2019ve got a 100Gb mailbox database, and recently some users have deleted content from their mailboxes, and a few mailboxes have also been deleted, there might be 10Gb of \u201cavailable new mailbox space\u201d in the database after those deleted items have been purged. The database file itself won\u2019t shrink, but if you were to move another 5Gb mailbox to that database, it wouldn\u2019t necessarily grow either, because it had 10Gb of \u201cavailable new mailbox space\u201d to place that data into.<\/p>\n<p>That\u2019s the simplest explanation I can provide without getting into a deep dive on ESE.<\/p>\n<p>Anyway, let\u2019s assume you\u2019re interested to know the size and available space in your mailbox databases, and you want to use\u00a0PowerShell\u00a0to retrieve that information.<\/p>\n<p>First, running\u00a0Get-MailboxDatabase\u00a0will return two properties that we\u2019re interested in;DatabaseSize\u00a0and\u00a0AvailableNewMailboxSpace. I\u2019m also retrieving the\u00a0Name\u00a0because I have multiple databases in this environment.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<pre>[PS] C:\\&gt;Get-MailboxDatabase | select Name,DatabaseSize,AvailableNewMailboxSpace\r\n\r\nName                        DatabaseSize AvailableNewMailboxSpace\r\n----                        ------------ ------------------------\r\nDB01\r\nDB02\r\nDB03\r\nDB04\r\nMailbox Database 1833569659\r\n\r\n\r\n<\/pre>\n<p>In the output above the attributes are blank. This is because I did not use the -Status parameter for Get-MailboxDatabase, which retrieves some extra details that the default cmdlet behaviour does not.<\/p>\n<pre>[PS] C:\\&gt;Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace\r\n\r\nName                        DatabaseSize                    AvailableNewMailboxSpace\r\n----                        ------------                    ------------------------\r\nDB01                        23.25 GB (24,964,497,408 bytes) 123 MB (128,942,080 bytes)\r\nDB02                        25.88 GB (27,783,069,696 bytes) 184 MB (192,970,752 bytes)\r\nDB03                        3 GB (3,221,225,472 bytes)      58.03 MB (60,850,176 bytes)\r\nDB04                        2.625 GB (2,818,572,288 bytes)  36.63 MB (38,404,096 bytes)\r\nMailbox Database 1833569659 768 MB (805,306,368 bytes)      179.8 MB (188,579,840 bytes)\r\n\r\n\r\n<\/pre>\n<p>Job done, right? Not quite. Those values are what we want to see, but they may not be useful for reporting purposes. For example, if I were to output that data to CSV file and open it in Excel, the values such as \u201c23.25 Gb (24,964,497,408 bytes)\u201d would not be very useful for sorting or graphing.<\/p>\n<p>So instead I prefer to convert the data to a useful, consistent format, generally a rounded number of GB.<\/p>\n<pre>[PS] C:\\&gt;Get-MailboxDatabase -Status | sort name | select name,@{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}}\r\n\r\nName                        DB Size (Gb) Available New Mbx Space Gb)\r\n----                        ------------ ---------------------------\r\nDB01                                  23                           0\r\nDB02                                  25                           0\r\nDB03                                   3                           0\r\nDB04                                   2                           0\r\nMailbox Database 1833569659            0                           0\r\n\r\n\r\n<\/pre>\n<p>In your case MB might be more useful, depending on the size of your environment and how you plan to use the data in Excel or other applications later.<\/p>\n<p>As you can see this is pretty simple information to retrieve, with the only issue being that command is a royal pain to remember and type in full each time you want to get the latest figures. So you will probably find it much easier to simply add that one-liner to a script file and run the script instead. That has the advantage of allowing you to add parameters to your script for specifying which databases to query, or to output the information to a specific format.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>As your\u00a0Exchange Server\u00a0mailbox databases grow you\u2019re eventually going to be interested in finding out two things \u2013 how large the database file is, and how much available new mailbox space is in the database. \u201cAvailable new mailbox space\u201d is sometimes referred to as \u201cwhite space\u201d, although the folks at Microsoft will tell you that is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[59],"tags":[],"class_list":["post-1586","post","type-post","status-publish","format-standard","hentry","category-powershell"],"_links":{"self":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1586","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1586"}],"version-history":[{"count":3,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1586\/revisions"}],"predecessor-version":[{"id":1588,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=\/wp\/v2\/posts\/1586\/revisions\/1588"}],"wp:attachment":[{"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1586"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1586"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/microsoftgeek.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1586"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}