There is an updated version of this article here.

As your Exchange Server mailbox databases grow you’re eventually going to be interested in finding out two things – how large the database file is, and how much available new mailbox space is in the database.

“Available new mailbox space” is sometimes referred to as “white space”, although the folks at Microsoft will tell you that is not the correct term for it. I’ll try to stick to the correct terminology in this article.

If you’re not sure what that “available new mailbox space” means, consider this example. Let’s say you’ve 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’ve 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 “available new mailbox space” in the database after those deleted items have been purged. The database file itself won’t shrink, but if you were to move another 5Gb mailbox to that database, it wouldn’t necessarily grow either, because it had 10Gb of “available new mailbox space” to place that data into.

That’s the simplest explanation I can provide without getting into a deep dive on ESE.

Anyway, let’s assume you’re interested to know the size and available space in your mailbox databases, and you want to use PowerShell to retrieve that information.

First, running Get-MailboxDatabase will return two properties that we’re interested in; DatabaseSize and AvailableNewMailboxSpace. I’m also retrieving the Name because I have multiple databases in this environment.

[PS] C:\>Get-MailboxDatabase | select Name,DatabaseSize,AvailableNewMailboxSpace

Name                        DatabaseSize AvailableNewMailboxSpace
----                        ------------ ------------------------
DB01
DB02
DB03
DB04
Mailbox Database 1833569659

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.

[PS] C:\>Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace

Name                        DatabaseSize                    AvailableNewMailboxSpace
----                        ------------                    ------------------------
DB01                        23.25 GB (24,964,497,408 bytes) 123 MB (128,942,080 bytes)
DB02                        25.88 GB (27,783,069,696 bytes) 184 MB (192,970,752 bytes)
DB03                        3 GB (3,221,225,472 bytes)      58.03 MB (60,850,176 bytes)
DB04                        2.625 GB (2,818,572,288 bytes)  36.63 MB (38,404,096 bytes)
Mailbox Database 1833569659 768 MB (805,306,368 bytes)      179.8 MB (188,579,840 bytes)

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 “23.25 Gb (24,964,497,408 bytes)” would not be very useful for sorting or graphing.

So instead I prefer to convert the data to a useful, consistent format, generally a rounded number of GB.

[PS] C:\>Get-MailboxDatabase -Status | sort name | select name,@{Name='DB Size (Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';Expression={$_.AvailableNewMailboxSpace.ToGb()}}

Name                        DB Size (Gb) Available New Mbx Space Gb)
----                        ------------ ---------------------------
DB01                                  23                           0
DB02                                  25                           0
DB03                                   3                           0
DB04                                   2                           0
Mailbox Database 1833569659            0                           0

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.

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.

About the Author

Paul Cunningham

Paul is a former Microsoft MVP for Office Apps and Services. He works as a consultant, writer, and trainer specializing in Office 365 and Exchange Server. Paul no longer writes for Practical365.com.

Comments

  1. dale holmes

    Those that dont get values back on that command.

    this is the command which works for me and returns values. probably the same for 2013. (eg. must include -status attribute)

    Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace

  2. Najkul

    It worked, thanks! 🙂

  3. Mark Young

    I have three Exchange Databases. Db01, 02, and 03. WHen I run the command above I get the following.

    Name DB Size (Gb) Available New Mbx Space Gb)
    —- ———— —————————
    DB01 450 13
    DB02 505 61
    DB03 326 11

    I have been told that my DBSizes are way to big, unfortunately I don’t have enough space to do anything about it. Do the numbers in Available Space show me how much I can reuse for new mail items (email, calendar, contacts, etc.) If so would it make sense to try to resize them all by moving mailboxes so that they are around 25GB each?

  4. Russell D'Arensbourg

    The code doesn’t seem to work. Is this deprecated or do I need to import something for this to function? I’m getting the “not recognized as name of cmdlet, function script…”

  5. Karol Kamiński

    After reading the entry it is easy. I also understood that the mailbox database only increases “global size” on disk volume. If we remove several mailboxes from the database, and additionally users of mailboxes will delete a bit @, then a free space aka “AvailableNewMailboxSpace” will be created. This free space with the current size of mailboxes in the database shows the “global size” of the database, which can only grow, not decrease. When we create a mailbox that does not exceed the free space in the database, then the global size of the mailbox database will not increase. If I understood this correctly, a similar idea is related to the Outlook .pst file. But with regard to the compacting of the pst file, the defrag database of mailboxes in DAG is probably a risky idea and a better approach is to move the mailboxes to the new database. Did I decompose it well?

  6. Aslan

    Hi Paul
    Great article thanks.
    How I can see free space on databases? Not availablenewmailboxspace.

  7. Bob Herman

    Hi:

    I removed approx. 100GB from two Exchange Server 2010 mailbox dBs by moving mailboxes to a different dB on a different disk. A backup using Windows Server Backup has since run (full backup on OS disk and Incremental backup on disk w/mailbox dBs).

    I expected lots of whitespace / availablenewmailboxspace to become available but it did not. The two mailbox dBs are showing very little whitespace, approx. 100MB only. Does it take a period of time for whitespace to become available?

    Thank you!

  8. Heckman

    Paul,
    when running the Get-MailboxDatabase -Status | sort name | select name,@{Name=’DB Size (Gb)’;Expression={$_.DatabaseSize.ToGb()}},@{Name=’Available New Mbx Space Gb)’;Expression={$_.AvailableNewMailboxSpace.ToGb()}} if find that some DB size’s are listed at 0 and of the 12 datastores I have, 6 show Zero Available New Mailbox Space.

    Does the 0 database size confirm that if I see no mailboxes in that database in the Recipient Configuration > mailbox view that I can remove that Database? (I would dismount it for 48 hours, wait for comments from end users and if nothing, then delete if that is the case)

    and

    if the available new mailbox space is showing 0 does that mean there is no room for growth for more emails for those in the associated datastores?

    -Z

  9. Augustus

    Great article. I’m fairly new to the PS. How can I modify the script sort to show DB size in descending order?

    Thanks,
    Augustus

    1. Mwilliam

      Any luck on this?

  10. Phu V. Huynh

    Hello,
    Is there a way to check if there is no mailbox exist in an Exchange 2013 database? I’ve moved all the online archive mailboxes from 1 database to a new database and would like to make sure that the old database is empty before I delete it.

    Thanks.

      1. Phu V. Huynh

        Thanks very much sir!

  11. Ravi Mohindroo

    You know, white space (Available space for new mailbox ) will be 0 when Physical free space is 100% or when Physical Free space is 0%, that was the confusion I had, I guess this answers it all. That’s why paul said ““Available new mailbox space” is sometimes referred to as “white space”, although the folks at Microsoft will tell you that is not the correct term for it.”

  12. rod san

    Thanks Paul, great article!

    Is there a way to reclaim the available space if these are DAG database copies on separate servers?

    I am running out of space on one of the servers.

    Can i just delete the database DAG copy on the server with low disk space and then reseed it?

    Thanks.

    1. Avatar photo
      Paul Cunningham

      If only one DAG member is low on space that suggests to me that you’ve provisioned different size storage volumes on each DAG member, which is not recommended.

      To answer your question, if you reseed the database you can expect it to be the same size it was before.

      If you want to shrink a DAG database, create a new database + copies, then move mailboxes. The “white space” doesn’t get moved, so the new database will be smaller.

      1. Gee Jacob

        Thanks Paul.
        However my situation is both DAG server disks configured with same size and are full with 5 DBs (utilized all Exchg standard licenses), so cant move mailboxes. Here could you advice , how can I reduce DB size..

        1. Jaap Wesselius

          Hi Gee Jacob,
          Paul is no longer writing for Practical365, so let me chime in on this one.
          Since you are using an Exchange Standard Edition, there isn’t a possibility to create a new mailbox database and move mailboxes to it. Another Exchange server could help, but I assume that’s not an option.
          The only thing that’s left is an offline defrag of your mailbox database. This means dismounting the database and using the ESEUTIL tool to defragment it. What is basically does is creating a new mailbox database (offline, so no worries about the standard edition license) and copy all the data from the old mailbox database to the new mailbox database. When done, it renames the new database to the old database name and that’s it. This will shrink the mailbox database. But remember, when you only have 1GB of new mailbox space (‘whitespace’) in your old mailbox database, running the ESEUTIL tool will only shrink it with 1 GB in size.
          For more information look at this page https://techcommunity.microsoft.com/t5/exchange-team-blog/repairing-exchange-databases-with-eseutil-when-and-how/ba-p/610276 (and scroll down for the ESEUTIL /D option)

  13. John Festa

    Great article. It was very helpful. Thanks!

  14. Nav Sangha

    HI, i ran Get-MailboxDatabase -Status | select Name,DatabaseSize,AvailableNewMailboxSpace i get alist of databases but still get blank attributes, i am running this on the exchange server itself and as an administrator.

  15. emile casanova

    Hi Paul,
    Can I get some help.. Run the powershell, it get error message below.

    [PS] C:\>Get-MailboxDatabase -Status | sort name | select name,@{Name=’DB Size (
    Gb)’;Expression={$_.DatabaseSize.ToGb()}},@{Name=’Available New Mbx Space Gb)’;E
    xpression={$_.AvailableNewMailboxSpace.ToGb()}}
    Select-Object : You cannot call a method on a null-valued expression.
    At line:1 char:49
    + Get-MailboxDatabase -Status | sort name | select <<<< name,@{Name='DB Size (
    Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';
    Expression={$_.AvailableNewMailboxSpace.ToGb()}}
    Select-Object : You cannot call a method on a null-valued expression.
    At line:1 char:49
    + Get-MailboxDatabase -Status | sort name | select <<<< name,@{Name='DB Size (
    Gb)';Expression={$_.DatabaseSize.ToGb()}},@{Name='Available New Mbx Space Gb)';
    Expression={$_.AvailableNewMailboxSpace.ToGb()}}

  16. MB Shaikh

    Hi Paul,

    Great informaiton thanks, when i run the command on exchange 2013 it show me the datbase size but AvailbleNewMailboxSpace is empty.

    How can I run it >

    Thanks .

  17. Kev

    Hi Paul
    Great article thanks. I have an issue with PS 5.0. I tried your code above and my results are blank. If I use this at the end of the code :

    | select database

    this produces a figure in GB’s. I am trying to convert to MB.

    Any ideas? Thanks

  18. Michail Galanakis

    Hi Paul
    thanks for the article.
    Is there a command in exchange 2010 that i can count the total size and the item count on a specific database for 2010 and before?
    Thanks in Advance
    Michail

  19. Shubhav Sharma

    Its Availablenewmailboxspace parameter in my above comments. Sorry for the typo.

  20. Shubhav Sharma

    Hi Paul ,

    Thanks for the great article. I have a query , we had one database of 800Gb and when I ran AvailableNewmailboxwhitespace it gave only 5GB. Then I added the size of all mailboxes including deleted items size which was around 700 GB. Then I decided to move all the mailboxes from old Db to new DB and was able to recover 100 GB.
    So AvailableNewmailboxwhitespace should not show 100 GB instead of 5GB?

    1. Avatar photo
      Paul Cunningham

      The difference may have been due to deleted items or mailboxes that hadn’t passed the retention period configured on the database before they are purged entirely.

  21. Brandy Reid

    Hi Paul,

    What impact of zero whitespace available?

    DB1 37.13 GB (39,871,119,360 bytes) 0 B (0 bytes)

    Thanks in Advance!
    Brandy

  22. Brandy Reid

    Thanks for sharing! I’ve piped these scripts into scheduled tasks that run weekly 🙂

  23. Joe

    Hi Paul,

    Great article, this has cleared a lot of confusion for me.

    Is there a way to clear this available space so that the database will decrease in size? I am working with a small company who have a 90GB database size but 35GB of available space, but they want to decrease the database size as backups are really slow for them.

    1. Avatar photo
      Paul Cunningham

      Yes. Create a new database, move the mailboxes to the new database, remove the old database.

    2. Joe

      Please ignore this, I have come across your article on defragging a database 🙂

      1. Avatar photo
        Paul Cunningham

        And hopefully you’re going to do the mailbox migration method instead.

  24. Vitaliy

    | Select Name, {$_.DatabaseSize.toKB()}
    also worked for me 🙂

  25. MikeK

    Paul, silly question I have; but I am somewhat new to PowerShell in general, though not new to scripting in Linux/Unix (Perl, etc), but when I run Get-MailboxDatabase on our Exchange 2010 server (that I inherited) it essentially tells me it is not there, and when I do a search for it I cannot find it on the system. I assume then that I have to load a package of some sort? I would think it would come stock, but I’m certainly missing something somewhere. Can you enlighten me as to where I might find this and other Exchange-type PowerShell scripts. I would greatly appreciate it.

    Thanks!

    1. Avatar photo
      Paul Cunningham

      Open the Exchange Management Shell, which is Powershell loaded with the modules for managing Exchange.

  26. RickF

    Nice article Paul. Thanks!
    .
    But when I originally ran this, the DatabaseSize and AvailableNewMailboxSpace columns’ outputs were empty (blank).
    .
    After some research, I discovered your code worked fine if I ran it using EMS on my Exchange 2013 (or 2010) servers directly. My problem was due to running a remote Exchange session using PowerShell (ISE) from my PC. Apparently in a remote session, Exchange converts the output to strings (not numbers as the output is when using EMS) – hence the “ToGb()” conversion won’t work.
    .
    Taking into account that I was working with strings, although a bit messy, I did get it to work with the following:
    .
    Get-MailboxDatabase -Status | sort name | select name,@{Name=’DB Size (Gb)’;Expression={[math]::Round((([double]($_.DatabaseSize -replace “(.*()|,| [a-z]*)”,””))/1000000000),2)}},@{Name=’Available New Mbx Space (Gb)’;Expression={[math]::Round((([double]($_.AvailableNewMailboxSpace -replace “(.*()|,| [a-z]*)”,””))/1000000000),2)}}
    .
    I arbitrarily chose 2 decimal places and GB for the output.
    .
    I suspect I might not be the only one who comes across this problem. I hope this saves somebody some time/effort. Thanks again.

    1. Avatar photo
      Paul Cunningham

      Yes, remoting is useful for management tasks, but sometimes cumbersome for reporting tasks as you see from your experience.

    2. Brady Witbeck

      This didn’t work for me (blank output). I wrote the following for Exchange 2010 that should work with Remote PowerShell as well. This spits out bytes as a [double], can be converted to MB/GB/etc with your math:

      Get-MailboxDatabase -Status | ForEach-Object{Select-Object -InputObject $_ -Property *,@{Name=”DatabaseSizeBytes”;Expression={[double](($_.DatabaseSize.Replace(“,”,””)) | Select-String “(?<=\().*(?= )" | Foreach-Object {$_.Matches} | Select-Object value).Value}}} | Sort-Object DatabaseSizeBytes | Select-Object Name,DatabaseSizeBytes

      Hope this helps!

  27. Charles

    Paul, what about Exchange 2010? Thanks

  28. Peter

    Hello Paul,

    how goes this work for public folders?

    Peter

Leave a Reply