Find replica servers (VBScript)
This code can be found in
Chapter 18 of Active Directory Cookbook, 2nd edition
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 VBScript code displays the DN of each domain controller's
' nTDSDSA object that is a replica server for the
' specified app partition
' ---------------------------------------------------------------
' From the book "Active Directory Cookbook" by Robbie Allen
' ISBN: 0-596-00466-4
' ---------------------------------------------------------------
' ------ SCRIPT CONFIGURATION ------
' Fully qualified DNS name of app partition
strAppPart = "<AppPartitionFQDN>" ' e.g. apps.rallencorp.com
' ------ END CONFIGURATION ---------
set objRootDSE = GetObject("LDAP://RootDSE")
strBase = "<LDAP://cn=Partitions," & _
objRootDSE.Get("ConfigurationNamingContext") & ">;"
strFilter = "(&(objectcategory=crossRef)(dnsRoot=" & strAppPart & "));"
strAttrs = "msDS-NC-Replica-Locations;"
strScope = "onelevel"
set objConn = CreateObject("ADODB.Connection")
objConn.Provider = "ADsDSOObject"
objConn.Open "Active Directory Provider"
set objRS = objConn.Execute(strBase & strFilter & strAttrs & strScope)
if objRS.RecordCount <> 1 then
WScript.Echo "Did not find a match for application partition " & _
strAppPart
WScript.Quit
else
objRS.MoveLast
if objRS.Fields("msDS-NC-Replica-Locations").Properties.Count > 0 then
Wscript.Echo "There are no replica servers for app partition " & _
strAppPart
else
Wscript.Echo "Replica servers for app partition " & strAppPart & ":"
for each strNTDS in objRS.Fields("msDS-NC-Replica-Locations").Value
WScript.Echo " " & strNTDS
next
end if
end if
|
This code has been viewed 2252 times.
|
New from the creators of TechTasks.com:
StatSheet.com
|