ABM Support
asked on
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.fi leSystemOb ject")
SET objRootDSE = CREATEOBJECT("LDAP://RootD SE")
configurationNamingContext = objRootDSE.GET("configurat ionNamingC ontext")
SET cn = CREATEOBJECT("ADODB.Connec tion")
SET cmd = CREATEOBJECT("ADODB.Comman d")
SET rs = CREATEOBJECT("ADODB.Record set")
cn.Open "Provider=ADsDSOObject;"
query = "<LDAP://" & configurationNamingContext & ">;(objectCategory=msExchP rivateMDB) ;name,cn,d istinguish edName;sub tree"
cmd.ActiveConnection = cn
cmd.CommandText = query
SET rs = cmd.EXECUTE
WHILE rs.EOF <> TRUE AND rs.BOF <> TRUE
' wscript.echo rs.Fields("distinguishedna me").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
Thanks
Steve
set fso = createObject("scripting.fi
SET objRootDSE = CREATEOBJECT("LDAP://RootD
configurationNamingContext
SET cn = CREATEOBJECT("ADODB.Connec
SET cmd = CREATEOBJECT("ADODB.Comman
SET rs = CREATEOBJECT("ADODB.Record
cn.Open "Provider=ADsDSOObject;"
query = "<LDAP://" & configurationNamingContext
cmd.ActiveConnection = cn
cmd.CommandText = query
SET rs = cmd.EXECUTE
WHILE rs.EOF <> TRUE AND rs.BOF <> TRUE
' wscript.echo rs.Fields("distinguishedna
' CHANGE FILE LOCATIONS HERE
strEDBPath = "E:\Program Files\Microsoft\Exchange Server\V14\Mailbox\Mailbox
' 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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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