Modifying powershell script to calculate the white space on Exchange Server 2010 using the script for Exchange Server 2007 ?

Posted on 2014-11-26
Last Modified: 2014-11-27

I need your help and suggestion in modifying the below Powershell script so that it can be used against Exchange Server 2010:

function Get-ExchangeWhiteSpace {
        $ComputerName = $(throw "ComputerName cannot be empty.")

      # Convert Dates to WMI CIM dates
            $tc = [System.Management.ManagementDateTimeconverter]
            $Start = $tc::ToDmtfDateTime( (Get-Date).AddDays(-10).Date )
            $End = $tc::ToDmtfDateTime( (Get-Date).Date)

      # Create two calculated properties for InsertionStrings values
            $DB = @{Name="DB";Expression={$_.InsertionStrings[1]}}
            $FreeMB = @{Name="FreeMB";Expression={[int]$_.InsertionStrings[0]}}

      Get-WMIObject Win32_NTLogEvent -ComputerName $ComputerName -Filter "LogFile='Application' AND EventCode=1221 AND TimeWritten>='$Start' AND TimeWritten<='$End'" |
        Select-Object ComputerName,$DB,$FreeMB, @{Name="TimeWritten"; Expression = {$_.ConvertToDateTime($_.TimeWritten )}} |
              Group-Object ComputerName, DB |
              % { $_.Group | Sort-Object TimeWritten -Descending | select -first 1 } | Sort-Object FreeMB -Descending

Get-ExchangeWhiteSpace -ComputerName PRODMAILBOX02-VM | ft -AutoSize

The above script works with no issues in Exchange Server 2007 but not in 2010.

LVL 16

Assisted Solution

by:Rajitha Chimmani
Rajitha Chimmani earned 250 total points
ID: 40468391
With Exchange 2010 whitespace is not calculated using any events. Its extracted from a command itself..just a single command.

Get-MailboxServer servername | Get-MailboxDatabase | ft Name,AvailableNewMailboxSpace

Author Comment

by:Senior IT System Engineer
ID: 40468398
Thanks Rajitha,

I'm not sure what happened to my Exchange Server 2010, but somehow by executing the Full List option as per below:

Get-MailboxServer | Get-MailboxDatabase | fl

Open in new window

The following attributes value is empty:

DatabaseSize                                 : 
AvailableNewMailboxSpace                     : 

Open in new window


Expert Comment

ID: 40468439

exchange 2010 sp1 it self bug while checking AvailableNewMailboxSpace on more database through EMS power shell,
Need to upgrade with rollup 6 or SP2

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.


Author Comment

by:Senior IT System Engineer
ID: 40468442
my exchange server version is below:

Exchange Server 2010 Version: 14.02.0387.000 (Build 247.5)

is that affected ?
LVL 31

Accepted Solution

Gareth Gudger earned 250 total points
ID: 40468503
Hey ITSystemEngineer,

You are on SP2. And I just confirmed this works on SP1 as well in my lab.

Try the following command. Its missing the -Status switch.

Get-MailboxServer servername | Get-MailboxDatabase -Status | ft Name,AvailableNewMailboxSpace

Author Closing Comment

by:Senior IT System Engineer
ID: 40469806
Thanks !
I didn't know if the new Exchange Server 2010 requires the Server name or additional parameter "-Status" to populate the attributes.

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to install and use the NTBackup utility that comes with Windows Server.
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
The basic steps you have just learned will be implemented in this video. The basic steps are shown to configure an Exchange DAG in a live working Exchange Server Environment and manage the same (Exchange Server 2010 Software is used in a Windows Ser…
how to add IIS SMTP to handle application/Scanner relays into office 365.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question