The Exchange 2007 Wiki

Get DB Size

Description

This is a script file that needs to be copied and saved locally.  This script file returns the size of a database on a server.

Usage

Save the script as a file named "get-dbsize.ps1".  Execute this script in PowerShell.

Sample Script

param(
 [string] $server = $env:computername
)

foreach ($db in get-mailboxdatabase -server $server) {

 $dbPath = $db.EdbFilePath -replace "\\","\\" # for use in the WMI filter
 $dbSize = (get-wmiobject cim_logicalfile -computer $server -filter "name='$dbPath'" -property filesize).filesize

 $retObj = new-object psobject
 $retObj | add-member noteproperty -name "Server" -value $db.Server
 $retObj | add-member noteproperty -name "Name"  -value $db.Identity
 $retObj | add-member noteproperty -name "Size (MB)" -value ("{0:n1}" -f ($dbSize/1MB))

 $retObj

}

 

 

Disclaimer: The sample scripts are meant to serve as examples and may need modifications before they will work in your environment. The authors of the script are not responsible for any negative outcome that may result from using them. 

Site

Changes
Index
Search

 

User

 

Log In
Register

 
 

Last Modified 8/21/07 7:35 AM