Saturday, August 15, 2009

To list the DB size in all mailbox server

This script can be used to list the each database size in the exchange org. This can be easily modified as per your need.

###############################################

# Script for finding all the database size in GB present in the organization.
# please use redirect '<' for reporting# Eg, .\Tofinddbsize.ps1 > report.txt

$exchangeservers = Get-ExchangeServer where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }

foreach ($server in $exchangeservers)
{
$db = Get-MailboxDatabase -server $server
foreach ($objItem in $db)
{
$edbfilepath = $objItem.edbfilepath

$path = "`\`\" + $server + "`\" + $objItem.EdbFilePath.DriveName.Remove(1).ToString() + "$"+ $objItem.EdbFilePath.PathName.Remove(0,2)

$dbsize = Get-ChildItem $path $ReturnedObj = New-Object PSObject

$ReturnedObj Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity

$ReturnedObj Add-Member NoteProperty -Name "Size (GB)" -Value ("{0:n2}" -f ($dbsize.Length/1024MB))

Write-Output $ReturnedObj
}
}

###############################################

Thanks

LOGAN

logu_microsoft@hotmail.com 971552596187

No comments: