You want a list of the domain controllers or global catalog servers in a specific site.
Open the Active Directory Sites and Services snap-in.
In the right pane, expand the site that contains the domain controller.
For the list of domain controllers, expand the Servers container.
To find the global catalog servers, expand each domain controller, right-click on NTDS Settings, and select Properties.
Global catalog servers will have the box checked beside Global Catalog.
The following query finds all domain controllers in specified site.
> dsquery server -site <SiteName>
To find only the global catalog servers in a site, use the same command with the -isgc option.
> dsquery server -site <SiteName> -isgc
' This code prints the domain controllers in a site and then ' prints the global catalog servers in the site ' ------ SCRIPT CONFIGURATION ------ strSite = "<SiteName>" ' e.g. Default-First-Site-Name strForest = "<ForestDNSName>" ' e.g. rallencorp.com ' ------ END CONFIGURATION --------- set objRootDSE = GetObject("LDAP://" & strForest & "/RootDSE") strADsPath = "<LDAP://cn=servers,cn=" & strSite & ",cn=sites," & _ objRootDSE.Get("configurationNamingContext") & ">;" strFilter = "(objectcategory=ntdsdsa);" strAttrs = "distinguishedName;" strScope = "SubTree" WScript.Echo "Domain controllers in " & strSite & ":" set objConn = CreateObject("ADODB.Connection") objConn.Provider = "ADsDSOObject" objConn.Open "Active Directory Provider" set objRS = objConn.Execute(strADsPath & strFilter & strAttrs & strScope) objRS.MoveFirst while not objRS.EOF Set objNTDS = GetObject("LDAP://" & objRS.Fields(0).Value) Set objServer = GetObject( objNTDS.Parent ) Wscript.Echo " " & objServer.Get("dNSHostName") objRS.MoveNext wend ' Global Catalog filter strFilter = "(&(objectcategory=ntdsdsa)(options=1));" WScript.Echo "" WScript.Echo "Global Catalogs in " & strSite & ":" set objRS = objConn.Execute(strADsPath & strFilter & strAttrs & strScope) objRS.MoveFirst while not objRS.EOF set objNTDS = GetObject("LDAP://" & objRS.Fields(0).Value) set objServer = GetObject( objNTDS.Parent ) Wscript.Echo " " & objServer.Get("dNSHostName") objRS.MoveNext wend
Each domain controller has a server object within the Servers container for the site it is a member of (e.g., cn=DC1,cn=Servers,cn=MySite, cn=site, cn=configuration, dc=rallencorp, dc=com). Since other types of servers can have server objects in a site's Servers container, domain controllers are differentiated by the nTDSDSA object that is a child of the server object (e.g., cn=NTDSSettings,cn=DC1,cn=Servers,cn=MySite, cn=site, cn=confiugration, dc=rallencorp, dc=com). Querying for this nTDSDSA objects will return a list of domain controllers in the site. Locating global catalog servers consists of the same query, except where the low-order bit of the options attribute of the nTDSDSA object is equal to 1.