How do I retreive Exchange Store pathnames via scripting

I have a requirement to retrieve Exhange store pathnames from a server using a script. Once I can achieve this I then want to acquire the actual store size for reporting purposes. I can achieve this by hard-coding my store path but I need this to be done automatically. The script I have so far is as below....any ideas or advice please? (This script maybe rubbish....not attempted anything like this before!)

Thanks

Steve

set fso = createObject("scripting.fileSystemObject")
SET objRootDSE = CREATEOBJECT("LDAP://RootDSE")
configurationNamingContext = objRootDSE.GET("configurationNamingContext")
   
SET cn = CREATEOBJECT("ADODB.Connection")
SET cmd = CREATEOBJECT("ADODB.Command")
SET rs = CREATEOBJECT("ADODB.Recordset")

cn.Open "Provider=ADsDSOObject;"
       
query = "<LDAP://" & configurationNamingContext & ">;(objectCategory=msExchPrivateMDB);name,cn,distinguishedName;subtree"

cmd.ActiveConnection = cn
cmd.CommandText = query
SET rs = cmd.EXECUTE

WHILE rs.EOF <> TRUE AND rs.BOF <> TRUE
      ' wscript.echo rs.Fields("distinguishedname").Value

      ' CHANGE FILE LOCATIONS HERE
      strEDBPath = "E:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox Database\Mailbox Database.edb"


      ' SCRIPT GETS FILE OBJECT HERE
      Set oEDB = fso.getFile(strEDBPath)


      ' SCRIPT SETS VARIABLES BASED UPON FILE SIZE HERE
      numEDBSize = oEDB.size

      ' SCRIPT ADDS THE TWO FILE SIZES HERE
      numTotalSize = numEDBSize

      ' FORMATTING SO IT OUTPUTS SIZE IN GB
      numTotalSize = (((numTotalSize /1024) /1024) /1024)

      'Delete the next line if you don't want this script to throw an error code
      if not err.number = 0 then numTotalSize = 99999999999999

      ' SCRIPT OUTPUTS THE SUM OF THE FILE SIZES
      wscript.echo numTotalSize

      rs.MoveNext
WEND
   
SET rs = NOTHING
SET cmd = NOTHING
SET cn = NOTHING
set oEDB = nothing
set fso = nothing
ABM SupportIT SupportAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
If you don't mind using Powershell you can accomplish this very easily. See below...
$Database = "database1"
Get-MailboxDatabase -Identity $database -Status | Select Name, DatabaseSize, AvailableNewMailboxSpace

Open in new window


Will.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ABM SupportIT SupportAuthor Commented:
Hi Will, thanks for the response.

I've tried the script which does work with a minor change to to the database name, however I also need to it to show the public database....any further advise?

Thanks

Steve
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VB Script

From novice to tech pro — start learning today.