Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Exchange2007 Database Size Power Shell Question 1

Status
Not open for further replies.

zoeythecat

Technical User
May 2, 2002
1,666
US
Is there a power shell command I can run on an Exchange2007 server that will give me the size of the database? In Exchange2010 there is the following command:

Get-MailboxDatabase -Status | select ServerName,Name,DatabaseSize
- When this command is run on Exchange2007 it lists the databases but without the size. Is there a different command I need to run that someone knows of?

TIA
 
That basic Exchange 2010 functionality does not exist in Exchange 2007, so this is what I use (credit to Karl Mitschke):

Code:
$exchangeservers = Get-MailboxServer 
#Get-ExchangeServer |where-object {$_.admindisplayversion.major -eq 8 -and $_.IsMailboxServer -eq $true }
$Jumbo = 1024 * 1024 
$AllServers = @()
foreach ($server in $exchangeservers)
{
    $db = Get-MailboxDatabase -Status -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    
	
	$DiskObj = get-WmiObject Win32_LogicalDisk -computerName $server | Where-Object { $_.DriveType -eq 3 -and $_.DeviceID -ieq  $objItem.EdbFilePath.DriveName}
	$FreeOnStorage = [int]($DiskObj.freespace / $Jumbo)
	$FreeOnStorageProc = [float](($DiskObj.freespace /$Jumbo) / ($DiskObj.size / $Jumbo))

    $start = $path.LastIndexOf('\')
    $dbpath = $path.Substring($start +1).remove($path.Substring($start +1).length -4)
    $mailboxpath = "$server\$dbpath"
    $mailboxcount = Get-MailboxStatistics -database "$mailboxpath" |measure-object
    $ReturnedObj = New-Object PSObject
    $ReturnedObj | Add-Member NoteProperty -Name "Server\StorageGroup\Database" -Value $objItem.Identity
    $ReturnedObj | Add-Member NoteProperty -Name "Size (MB)" -Value ("{0}" -f ($dbsize.Length/1024KB))
    $ReturnedObj | Add-Member NoteProperty -Name "Mailbox Count" -Value $mailboxcount.count
	$ReturnedObj | Add-Member NoteProperty -Name "LastFullBackup" -Value $objItem.LastFullBackup
	$ReturnedObj | Add-Member NoteProperty -Name "LastIncrementalBackup" -Value $objItem.LastIncrementalBackup
	$ReturnedObj | Add-Member NoteProperty -Name "BackupInProgess" -Value $objItem.BackupInProgess
	$ReturnedObj | Add-Member NoteProperty -Name "Mounted" -Value $objItem.Mounted          
	$ReturnedObj | Add-Member NoteProperty -Name "IssueWarningQuota" -Value $objItem.IssueWarningQuota    
	$ReturnedObj | Add-Member NoteProperty -Name "ProhibitSendQuota" -Value $objItem.ProhibitSendQuota
	$ReturnedObj | Add-Member NoteProperty -Name "ProhibitSendReceiveQuota" -Value $objItem.ProhibitSendReceiveQuota
	$ReturnedObj | Add-Member NoteProperty -Name "MailboxRetention" -Value $objItem.MailboxRetention                                                  
	$ReturnedObj | Add-Member NoteProperty -Name "FreeOnStorage" -Value $FreeOnStorage 
	$ReturnedObj | Add-Member NoteProperty -Name "FreeOnStorageProc" -Value $FreeOnStorageProc   
    $AllServers += $ReturnedObj
    }
}

$AllServers | ft -AutoSize

Dave Shackelford
ThirdTier.net
TrainSignal.com
 
Dave,

Thanks for the reply. So, I need to copy and paste this entire command (obviously substituting for the servers in my environment)
 
If you add
Code:
> c:\sizeoutput.txt
to the end of that last line, you will be able to see the four lines of information that get dropped from the results when you view it from the command-line.

Dave Shackelford
ThirdTier.net
TrainSignal.com
 
Cool...Thanks...That gives me an output option I can forward the boss when need be.

Appreciate it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top