Wednesday, February 2, 2011

How to Get Exchange 2010 database Statistics - including DB White Space.

Hi all,
Here I go again (WhiteSnake 1984   :) )..copy/paste the below code in a ps1 file and you will get the white space, server name, database name, last full backup, user counts..etc

  $Databases = Get-MailboxDatabase -Status  
  foreach($Database in $Databases) {       
  $DBSize = $Database.DatabaseSize       
  $MBCount = (Get-Mailbox -Database $Database.Name).Count        
  $MBAvg = $DBSize.ToBytes() / $MBCount                     
 New-Object PSObject -Property @{            
 Server = $Database.Server.Name            
 DatabaseName = $Database.Name            
 LastFullBackup = $Database.LastFullBackup            
 MailboxCount = $MBCount           
 "DatabaseSize (GB)" = "{0:n2}" -f ($DBSize.ToBytes() / 1GB)           
  "AverageMailboxSize (MB)" = "{0:n2}" -f ($MBAvg / 1MB)           
  "WhiteSpace (MB)" = "{0:n2}" -f ($Database.AvailableNewMailboxSpace.ToBytes() / 1MB) 
 }     }


The output should be something like that:

Enjoy!

-Dario

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.