A. The following script, which you can download here , accepts a domain as its parameter, then lists all DCs in that domain. Some lines wrap because of space constraints.

Const ADS_SCOPE_SUBTREE = 2

If Wscript.Arguments.Count required. For example:" & vbCrLf _ & "cscript listdcs.vbs dc=savilltech,dc=com" Wscript.Quit(0) End If

strDomainName = Wscript.Arguments(0)

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

objCommand.CommandText = _ "Select distinguishedName from " & _ "'LDAP://cn=Configuration," & strDomainName & "' " _ & "where objectClass='nTDSDSA'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE

Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst

Do Until objRecordSet.EOF DCDN = objRecordSet.Fields("distinguishedName").Value DomainController = Mid(DCDN,21,InStr(Mid(DCDN,21),",")-1) Wscript.Echo "Domain Controller: " & DomainController objRecordSet.MoveNext Loop

This sample execution produced the following output when I ran it on my system:

D:\Temp>cscript listdcs.vbs dc=savilltech,dc=com

Domain Controller: SAVDALDC01
Domain Controller: SAVDALDC02
Domain Controller: SAVLONDC01
Domain Controller: SAVDALLABDC01