Enum mailboxes (VBScript)
This code can be found in
Chapter 6 of Exchange Server Cookbook
Purchase XP Cookbook or Networking Recipes for only $25 plus shipping! While supplies last.
Find out how to download all of the VBScript code from this site.
' This script was originally published in the Exchange Cookbook,
' (http://www.exchangebookcook.com). Written by Paul Robichaux,
' Missy Koslosky, and Devin Ganger. Redistributed with permission
' of the publisher, O'Reilly & Associates.
' This script enumerates all the mailboxes in each database in each
' storage group.
' ------ SCRIPT CONFIGURATION ------
strBase = "<LDAP://batman>;" ' <serverName>" ' "batman"
strComputerName = "batman"
strAttrs = "cn;"
strScope = "subtree"
' ------ END CONFIGURATION ---------
set theServer = CreateObject("CDOEXM.ExchangeServer")
Set theSG = CreateObject("CDOEXM.StorageGroup")
Set theConn = CreateObject("ADODB.Connection")
theConn.Open "Provider=ADsDSOObject;"
theServer.DataSource.Open strComputerName
' examine the SGs; for each SG, iterate through its databases and
' list the mailboxes in it
For Each sg In theServer.StorageGroups
WScript.Echo "Storage group " & Chr(34) & sg & Chr(34)
theSG.DataSource.open sg
i = 0
For Each mailDB In theSG.MailboxStoreDBs
i = i+1
WScript.Echo " Mailbox database " & i & ": " & mailDB
wscript.Echo " Users: "
Set objRS = theConn.Execute(strBase & "(homeMDB=" & mailDB & ");" & strAttrs & strScope)
objRS.MoveFirst
While Not objRS.EOF
wscript.echo " " & objRS.Fields(0).Value
objRS.MoveNext
Wend
wscript.echo Chr(13) & Chr(13)
Next
Next
|
This code has been viewed 1847 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|