Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 346
  • Last Modified:

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

Folks,

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 {
      param(
        $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.

Thanks,
0
Senior IT System Engineer
Asked:
Senior IT System Engineer
2 Solutions
 
Rajitha ChimmaniCommented:
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
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
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

0
 
jimmithakkarCommented:
Hi,

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


Thanks
0
NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

 
Senior IT System EngineerIT ProfessionalAuthor Commented:
my exchange server version is below:

Exchange Server 2010 Version: 14.02.0387.000 (Build 247.5)

is that affected ?
0
 
Gareth GudgerCommented:
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
0
 
Senior IT System EngineerIT ProfessionalAuthor Commented:
Thanks !
I didn't know if the new Exchange Server 2010 requires the Server name or additional parameter "-Status" to populate the attributes.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now