Exchange_2010_logo_www.oostdam.infoExchange Server 2010 is a really beautifull product from Microsoft. Ofcourse these kind of products have difficulities of there own, but generally, there functionality is great. With the integration of the Exchange Powershell command line tools, the products took a great step forward, allowing (exchange)administrators lots of (scripting) possibilities and remote control of servers. This serie of articles has been made to share knowledge and provide some basic default scripting, which can be used on a (daily) basis through Exchange Powershell.  It can be an extra value for every organisation as "knowing" and "numbers" can be used to discover (data)trends, excessions and as a basis for decisions and policies. Have fun using powershell for Exchange !

List the whitespace available in each Exchange Mailboxdatabase:
This powershell line has been made to view and export the available whitespace whithin all your the Exchange 2010 Mailboxdatabases. It indicates quite good the available free space where mails and attachments can be stored for users that have their mailbox within that maildatabase. If the whitespace it not enough, the database will automatically expand if the whitespace is to low and that can cause storage problems. Thats not a real problem when it concerns a virtual server, but keep in mind that a store will dismount itself when expanding is not possible. Even worse,.... An Exchange database will automatically stop sending and receiving mails, when there is less then 3GB available diskspace left free on a drive. Just to protect itself. Now how do you determine the whitespace? Open the Exchange shell with administrative priviliges. The command is now:

Get-MailboxDatabase -Status | Select Servername, Name, AvailableNewmailboxSpace
( where Servername is the bios name of your Exchange Storage server ) and you will get an output on screen like underneath:

ServerName Name  AvailableNewMailboxSpace
===================== ============================================
YOUR_EXCHANGE_SERVERNAME Mailbox Database 0680693351 610.5 MB (640,188,416 bytes)
YOUR_EXCHANGE_SERVERNAME Standard Mailbox Size         4.319 GB (4,637,229,056 bytes)
YOUR_EXCHANGE_SERVERNAME Webmail 94.84 MB (99,450,880 bytes)
YOUR_EXCHANGE_SERVERNAME MigrationDatabase365 MB (382,763,008 bytes)

The same output, but with all the data on a separate line... you can get with the next command:

Get-MailboxDatabase -Status | FL Name, AvailableNewMailboxSpace
(I left the Severname out on purpose, I guess you can figure that out yourself!)
The output will then be something like underneath:

Name                     : Mailbox Database 0680693351
AvailableNewMailboxSpace : 610.5 MB (640,188,416 bytes)
Name                     : Standard Mailbox Size
AvailableNewMailboxSpace : 4.319 GB (4,637,294,592 bytes)
Name                     : Webmail
AvailableNewMailboxSpace : 94.84 MB (99,450,880 bytes)
Name                     : MigratieDatabase
AvailableNewMailboxSpace : 365 MB (382,763,008 bytes)

The uppermailbox name is created when you install exchange with the default Next, next...Finish; and the naming is a random 10 digit number. This is the first thin I look for within an installation the first time to see if the basic or advanced install was done. A good indication for the whole design, setup and post-installation needs! What more do we see?  The sizes are by default displayed in bytes, but please notice that an indication for GB and MB is present. Watch this carefully as it might be confusing sometimes. :-)

Now for the rest of the options,.. There are several present.
Most extra objects used are the DatabaseSize and the LastFullBackup options.

I happen to have a colleaque that has the dedicated task to controle the daily backups, so I leave the last option for what it is.
Adding the DatabaseSize Object result in my favorite commandline:

Get-MailboxDatabase -Status | Select Servername, Name, DatabaseSize, AvailableNewmailboxSpace
(Again you can figure out how to add the objects yourself!)

If this output (onscreen) scrambles up your data so it becomes hardly readable,... you can use the Pipe -AutoSize option:
Get-MailboxDatabase -Status | Select Servername, Name, DatabaseSize, AvailableNewmailboxSpace | Format-Table -AutoSize
This reduces your column width, and that does not matter, because I expect you to know what you are looking for after doing this 6 times.

Creating this for use in a scheduled powershell ps1 script will need a little extra command at front.
You can copy/paste the following text and save it as a PS1 file with the name of your choice. Call it exportmailboxsize.ps1 or something like that.  
- - - - - - - - - - - - - - - - - - -
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010
Get-MailboxDatabase -Status | Select Servername, Name, DatabaseSize, AvailableNewmailboxSpace > C:\Scripts\Whitespace.txt
- - - - - - - - - - - - - - - - - - -

Possible signing errors:
You have to tell Exchange 2010 and 2007 that they can trust other ps1 scripts then the default set that comes along with the installation. This is a one time command, after that Powershell for Exchange will trust and execute custom made scripts. The command is: Set-ExecutionPolicy RemoteSigned Please be aware of that. I often run this command manually first en set it back after I'm done, but everyone should make these security decisions for there own.

Remote availability & what to do with the report:
You can run this powershell command from, and towards, another Exchange server, if you have sufficiënt administrative rights. You can copy/paste the results to a shared directory to your customer, or make it available for your internal organisation on a sharepoint/intranet site if you have one available. Please do not share folders for "everyone" and always dubble check the permissions granted. Some reports can contain delicate information and you do not want that, ever, to get internally, or worse, publicly, available. Again, please pay extra attention to this. Creating a scheduled task and mailing the reports to a person might be a nice work-around. See the next lines on how to create a scheduled task.

Creating a scheduled task in Windows 2008(R2):
When you are using Windows 2008 server, this is very easy. Create a scheduled basic task and choose for the email option. The rest shows itselfs almost. A little extra attention for the re-run, wake-on-lan, and retry options will be necessary. Also, by default, the report/mail will not run until the user who created the task is loggend on. To solve that, please check the radio-button "Run whether user is logged on or not" on the General Tab, and it will always run on the scheduled time. Please always use a special service account for running and scheduling reports of this kind. When it is compromised, you can rather easiily change it. Do not, ever, use your own (admin)account or administrator account to schedule reports or mails.

I probally do not have to remind you, that you should always use scripts with care.
Therefore this posting is "as is" without express or implied warranty.
I would be nice though, if you put this line # Created by - Ben Oostdam  in the first line of your PS1 file.
Just for my efforts to create this article, which you must like if you've read it this far. 

Tip: Implement the writing of the free whitespace to the eventlog, and you can monitor it any way you would want to.

Printscreen: not available

Ben OostdamBen Oostdam has been working with Windows systems since 1993. Worked for several companies as a system administrator, and is currently a Senior Support Engineer for a large company in the Netherlands.

Disclaimer: The information contained in this website/article is for general information purposes only. The information is provided as is, by Ben Oostdam and others, and while we endeavour to keep the information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or the information, products, services, or related graphics contained on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will we be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website. Through this website you are sometimes able to link to other websites which are not under my control. I have no control over the nature, content and availability of those sites. The inclusion of any links does not necessarily imply a recommendation or endorse the views expressed within them. Every effort is made to keep the website up and running smoothly. However, I take no responsibility for, and will not be liable for, the website being temporarily unavailable due to technical issues beyond our control. All entries in these articles, are my individual opinion, or from co-writers, and they don't necessary reflect the opinion of my employer.


Friday the 7th, May 2021. All rights reserved.. // Oostdam WebDesign