Iterating Exchange Public Folder Tree

Discussion in 'Scripting' started by Mark Jefferson, Jun 28, 2005.

  1. Hello All,

    I have some simple code to list the properties of a folder tree. It runs
    ok but doe not list the AssociatedPublicStores attribute which I assume I use
    to walk the subtree. Is this possibly a permissions issue ?

    The script is as follows

    On Error Resume Next
    Dim cComputerName
    Const cWMINameSpace = "root/MicrosoftExchangeV2"
    Const cWMIInstance = "Exchange_FolderTree"
    cComputerName = "vm2003"

    Dim strWinMgmts ' Connection string for WMI
    Dim objWMIExchange ' Exchange Namespace WMI object
    Dim listExchange_FolderTrees ' ExchangeLogons collection
    Dim objExchange_FolderTree ' A single ExchangeLogon WMI object

    ' Create the object string, indicating WMI (winmgmts), using the
    ' current user credentials (impersonationLevel=impersonate),
    ' on the computer specified in the constant cComputerName, and
    ' using the CIM namespace for the Exchange provider.
    strWinMgmts = "winmgmts:{impersonationLevel=impersonate}!//"& _
    cComputerName&"/"&cWMINameSpace
    Set objWMIExchange = GetObject(strWinMgmts)
    ' Verify we were able to correctly set the object.
    If Err.Number <> 0 Then
    WScript.Echo "ERROR: Unable to connect to the WMI namespace."
    Else
    '
    ' The Resources that currently exist appear as a list of
    ' Exchange_FolderTree instances in the Exchange namespace.
    Set listExchange_FolderTrees = objWMIExchange.InstancesOf(cWMIInstance)
    '
    ' Were any Exchange_FolderTree Instances returned?
    If (listExchange_FolderTrees.count > 0) Then
    ' If yes, do the following:
    ' Iterate through the list of Exchange_FolderTree objects.
    For Each objExchange_FolderTree in listExchange_FolderTrees
    Wscript.Echo""
    Wscript.Echo""
    '
    ' Display the value of the AdministrativeGroup property.
    WScript.echo "AdministrativeGroup = "& _
    " ["&TypeName(objExchange_FolderTree.AdministrativeGroup)&"] "& _
    objExchange_FolderTree.AdministrativeGroup
    '
    '
    ' Display the value of the AdministrativeNote property.
    WScript.echo "AdministrativeNote = "& _
    " ["&TypeName(objExchange_FolderTree.AdministrativeNote)&"] "& _
    objExchange_FolderTree.AdministrativeNote
    '
    '
    ' Display the value of the AssociatedPublicStores property.
    '
    ' **************
    ' * not working *
    ' **************
    WScript.echo "AssociatedPublicStores = "& _
    " ["&TypeName(objExchange_FolderTree.AssociatedPublicStores)&"] "& _
    objExchange_FolderTree.AssociatedPublicStores
    '
    '
    ' Display the value of the CreationTime property.
    WScript.echo "CreationTime = "& _
    " ["&TypeName(objExchange_FolderTree.CreationTime)&"] "& _
    objExchange_FolderTree.CreationTime
    '
    '
    ' Display the value of the GUID property.
    WScript.echo "GUID = "& _
    " ["&TypeName(objExchange_FolderTree.GUID)&"] "& _
    objExchange_FolderTree.GUID
    '
    '
    ' Display the value of the HasLocalPublicStore property.
    WScript.echo "HasLocalPublicStore = "& _
    " ["&TypeName(objExchange_FolderTree.HasLocalPublicStore)&"] "& _
    objExchange_FolderTree.HasLocalPublicStore
    '
    '
    ' Display the value of the LastModificationTime property.
    WScript.echo "LastModificationTime = "& _
    " ["&TypeName(objExchange_FolderTree.LastModificationTime)&"] "& _
    objExchange_FolderTree.LastModificationTime
    '
    '
    ' Display the value of the MapiFolderTree property.
    WScript.echo "MapiFolderTree = "& _
    " ["&TypeName(objExchange_FolderTree.MapiFolderTree)&"] "& _
    objExchange_FolderTree.MapiFolderTree
    '
    '
    ' Display the value of the Name property.
    WScript.echo "Name = "& _
    " ["&TypeName(objExchange_FolderTree.Name)&"] "& _
    objExchange_FolderTree.Name
    '
    '
    ' Display the value of the RootFolderURL property.
    WScript.echo "RootFolderURL = "& _
    " ["&TypeName(objExchange_FolderTree.RootFolderURL)&"] "& _
    objExchange_FolderTree.RootFolderURL
    '
    Next
    Else
    ' If no Exchange_FolderTree instances were returned,
    ' display that.
    WScript.Echo "WARNING: No Exchange_FolderTree instances were returned."
    End If
    End If
     
    Mark Jefferson, Jun 28, 2005
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.