Announcement

Collapse
No announcement yet.

Unable to retrieve Exchange data with WMI

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Unable to retrieve Exchange data with WMI

    I am trying to write a script to retrieve mailbox sizes by storage group/database via WMI and dump them in a text file. I came across "AllMailboxes.vbs" developed by Alan Kaplan and have made some modifications to it that are mostly working.
    I am running into a problem when modifying the SQL part of the script to only search a particular server. Please take a look at my code.
    For the example below, I used a Like clause.

    strWinMgmts = "winmgmts:{ImpersonationLevel=Impersonate, AuthenticationLevel=PktPrivacy}!//" & strExchServer & "/" & cWMINameSpace
    wscript.echo strwinmgmts
    Set objWMIExchange = GetObject(strWinMgmts)
    ' Verify we were able to correctly set the object.
    If Err.Number <> 0 Then
    MsgBox "ERROR: Unable to connect to WMI. " & err.description,vbCritical+ vbOKOnly,"Error contacting " & strExchServer
    Else
    ' I found this to be faster than using instances in Zinman's script -- A
    WScript.Echo VbCrLf & vbTab & "Getting Mailbox info from " & strExchServer & "."
    Dim iBoxcount

    Set collEMailBoxes = objWMIExchange.ExecQuery("Select * from Exchange_Mailbox Where ServerName Like 'RH%'")

    This comes back stating that there was no data to be returned. I am scripting newbie, but eager to learn, go easy on me.

  • #2
    Re: Unable to retrieve Exchange data with WMI

    Originally posted by Flipg123 View Post
    Set collEMailBoxes = objWMIExchange.ExecQuery("Select * from Exchange_Mailbox Where ServerName Like 'RH%'")
    Let's simplify the query and see if there is any data available at all. What is the result if you change the query like so:

    Code:
    "Select * from Exchange_Mailbox"
    This will return all data from Exchange_Mailbox. If data is available, then only the where part needs tuning. If no data is available, the source might be invalid.

    -vP

    Comment

    Working...
    X