Jump to content

Script to find the mailbox database size in Exchange 2007


Recommended Posts

Posted (edited)

Hi

 

I use exchange 2007 and have a Mailbox database.

On the exchange EMC, Server configuration-Mailbox- Database Management and under

 

First storage group

Mailbox Database

 

Database file path

D:\ExchangeDB\Mailbox Database.edb

 

I would like to know the total size of the Mailbox Database.edb

Please see the link below and I came across this forum.

 

https://social.technet.microsoft.com/Forums/scriptcenter/en-US/7d0cebf5-5eac-4399-b07b-bab408019b2d/get-exchange-mailbox-database-size-in-exchange-2007?forum=ITCG

 

Please can the exact syntax be provided to find the size of mailbox database size?

Any help will be great.

Edited by genesis
Posted

$db = "Mailbox Database"

Get-MailboxDatabase -identity $db | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter ('name=''' + $_.edbfilepath.pathname.replace("","") + '''')).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

  • Thanks 1
Posted

Our mail server name is :BHE

and the Database file path is D:\ExchangeDB\Mailbox Database.edb

 

I am not completely sure as where all to put the appropriate values in the syntax .Please substitute the values and pot me the script.

 

Thanks

Posted
So when you open the exchange powershell on the mail box server you should just be able to use the script as is above. The only value you need is the mail box DB name, the rest is just getting info from the DB and server and formatting the data.
  • Thanks 1
Posted

The mail box database name is : Mailbox database.edb

Is the syntax correct?

 

$db = "Mailbox Database.edb"

Get-Mailbox Database.edb -identity $db | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter ('name=''' + $_.edbfilepath.pathname.replace("","") + '''')).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

Posted (edited)

This is what I use on Exchange 2010 (should still work for 2007) I think this will give you what you need in a more granulated form.

 

Database size is how big your edb is,

available space is database whitespace that can be filled before the edb will grow again.

 

White space is generated by house keeping rules that delete emails from the database. that space is never recovered in physical space on the volume until database maintenance is performed

 


Get-MailboxDatabase -Status | ft name,databasesize,availablenewmailboxspace -auto
[/Code]

 

Edit - adding edbfilepath will do what is says on the tin

[Code]
Get-MailboxDatabase -Status | ft name,databasesize,availablenewmailboxspace,edbfilepath -auto
[/Code]

Edited by dapaulio
  • Thanks 1
Posted

if you want to export a list of mailboxes within all your database and find their sizes then this ps command will help

Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,ItemCount,TotalItemSize,DeletedItemCount,TotalDeletedItemSize | Export-CSV c:\11122012.csv

  • Thanks 1
Posted (edited)

When I executed the first code it gave the name of the databases and on the second code I added the file path of the

D:\ExchangeDB\Mailbox Database.edb and I get this error below.Please let me know if I am putting nay wrong information on the code to find the database size of Mailbox databse.edb

 

[PS] C:\Windows\system32>Get-MailboxDatabase -Status | ft name,databasesize,avai

lablenewmailboxspace -auto

 

Name databasesize availablenewmailboxspace

---- ------------ ------------------------

Mailbox Database

Student Mailboxes

 

 

[PS] C:\Windows\system32>Get-MailboxDatabase -Status | ft name,databasesize,avai

lablenewmailboxspace,D:\ExchangeDB\Mailbox Database.edb -auto

Format-Table : A positional parameter cannot be found that accepts argument

'Database.edb'.

At line:1 char:31

+ Get-MailboxDatabase -Status | ft

name,databasesize,availablenewmailboxspace,D:\E ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

~~~

+ CategoryInfo : InvalidArgument: (:) [Format-Table], ParameterBi

ndingException

+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell

.Commands.FormatTableCommand

 

[PS] C:\Windows\system32>

Edited by genesis
Posted (edited)

Sorry should have been more detailed the code is powershell but you need to run it in Exchange Management Shell (EMS) as this will load additional cmdlets. the version of exchange may not support some of the cmdlets

 

you don't need to change the code. just copy and paste the line in to EMS

Edited by dapaulio
  • Thanks 1
Posted (edited)

Capture.JPGSorry should have been more detailed the code is powershell but you need to run it in Exchange Management Shell (EMS) as this will load additional cmdlets. the version of exchange may not support some of the cmdlets

 

you don't need to change the code. just copy and paste the line in to EMS

Edited by dapaulio
  • Thanks 1
Posted

Hi

Please see the attached snapshot and this is information I get and doesn't give the size under the databasesize.

Do you want me to post additional cmdlets of exchange 2007Snapshot of the result.png

Posted

Hi

I used the codes as HPlum78 posted , I only put only the Mailbox Database and removed the .edb and it showed me the data base size.

Thanks for all your help and suggestions.

 

$db = "Mailbox Database"

Get-MailboxDatabase -identity $db | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter ('name=''' + $_.edbfilepath.pathname.replace("","") + '''')).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

Posted

I have read that the cmdlets are only available in 2010 and other cmdlets from 2010 cu3 .

 

I saw this ps script but when I tested it on mine exchange it would not populate all the databases information. I ran the script multiple times and I would get varying outputs. Like the script was timing out half way through.

 

Glad this worked for you

  • Thanks 1

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



×
×
  • Create New...