切换到宽版
  • 5238阅读
  • 1回复

[求助]使用脚本列出Exchange存储对象的数量 [复制链接]

上一主题 下一主题
 
只看楼主 倒序阅读 0楼  发表于: 2011-03-11
— 本帖被 YOYO 从 Exchange 脚本中心 移动到本区(2015-06-25) —
  • 脚本环境:Visual Basic
  • 适合版本:Exchange 2003
  • 适用平台:
  • 脚本作用:列出Exchange存储对象的数量
使用此脚本可以输入组织名称和Exchange存储对象的数量。


'Outputs the current number of objects
'in each of the stores in the organization.
'Useful for load balancing mailboxes across
'servers and such.

On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
Dim arrStores()
intStores = 0

Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

objCommand.CommandText = _
    "SELECT distinguishedName FROM 'LDAP://CN=Administrative Groups,CN=YourOrgName,CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=Contoso,DC=Com' WHERE " _

        & "objectClass = 'msExchPrivateMDB'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst

Do Until objRecordSet.EOF
        ReDim Preserve arrStores(intStores)
        arrStores(intStores) = "LDAP://" & objRecordSet.Fields("distinguishedName").Value
        intStores = intStores + 1
        objRecordSet.MoveNext
Loop

For Each strStore in arrStores
                intMembers = 0
                Set objStore = GetObject(strStore)
                arrMembers = objStore.GetEx("homeMDBBL")
                For Each strMember in arrMembers
                        intMembers = intMembers + 1
                Next
                WScript.Echo objStore.Name & " has " & intMembers & " objects."
Next
分享到
只看该作者 1楼  发表于: 2011-03-11
不错,学习了
快速回复
限60 字节
 
上一个 下一个