' 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 code uses ADO to query the MSExchServerRole attribute for all servers
' in the domain.
' --------------SCRIPT CONFIGURATION------------------
strBase = "<LDAP://cn=administrative groups,cn=<orgName>,cn=microsoft exchange,cn=services,cn=configuration,<domain>" ' dc=<domain>,dc=<tld>;"
strFilter = "(objectcategory=MSExchExchangeServer);"
strAttrs = "ServerRole,cn;"
strScope = "subtree"
'---------------END CONFIGURATION---------------------
Set objConn = CreateObject("ADODB.Connection")
objConn.Open "Provider=ADsDSOObject;"
Set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
objRS.MoveFirst
While Not objRS.EOF
strName = objRS.Fields("cn").value
'Get the value of the MSExchServerRole
If objRS.Fields("ServerRole").value = 1 Then
strRole = "Front-End Server"
Elseif IsNull(objRS.Fields("ServerRole").value) Then
strRole = "Back-End Server"
Elseif objRS.Fields("ServerRole").value = 0 Then
strRole = "Back-End Server"
end if
wscript.echo strName & " is a " & strRole
objRS.MoveNext
Wend
|