Exchange Server Share

May 19, 2008

Powershell – Exchange 2003 EDB & STM File Size

Filed under: Exchange, Exchange 2003, PowerShell, Script — Amit Tank @ 3:52 am
Tags: ,

Here is the code to find the EDB & STM file size of Exchange 2003 server with Powershell.

 

This works when EDB and STM file are in same folder.

 

$server = “ATS-Exch301″ # Give Server Name Here

foreach ($DB in get-mailboxdatabase -server $server)

{

$DBEDBPath = “name=’” + $DB.EdbFilePath.ToString().Replace(“\”,”\\”) + “‘”

$DBSTMPath = $DBEDBPath.replace(“edb”,”stm”)

 

$DBEDBSize = (get-wmiobject CIM_Datafile -filter $DBEDBPath -ComputerName $Server).filesize

$DBSTMSize = (get-wmiobject CIM_Datafile -filter $DBSTMPath -ComputerName $Server).filesize

 

$DBEDBSize = $DBEDBSize / 1MB

$DBSTMSize = $DBSTMSize / 1MB

 

Write-host $DB.identity `t $DBEDBSize `t $DBSTMSize

}

1 Comment

  1. Kewl script buddy. made one hack to get the actual paths from the AD ;-)

    $DBdn = $DB.DistinguishedName
    $ADobj = New-Object DirectoryServices.DirectoryEntry “LDAP://$DBdn” | select *

    $DBedbPath = “name=’” + $ADobj.msExchEDBFile.ToString().Replace(“\”,”\\”) + “‘”
    $DBstmPath = “name=’” + $ADobj.msExchSLVFile.ToString().Replace(“\”,”\\”) + “‘”

    Comment by Paul Flaherty — May 29, 2008 @ 10:19 am


RSS feed for comments on this post.

Blog at WordPress.com.