1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | ' Lists all domain controllers in domain ' ' Run this via Cscript or direct output to text ' ' ListDCs.vbs Dim RootDSE, ConfigNC, Connection, Command, RecordSet, DC ' CALLOUT A Set RootDSE = GetObject("LDAP://rootDSE") ConfigNC = RootDSE.Get("configurationNamingContext") ' END CALLOUT A Set Connection = CreateObject("ADODB.Connection") Connection.Open("Provider=ADsDSOObject;") Set Command = CreateObject("ADODB.Command") Command.ActiveConnection = Connection ' CALLOUT B Command.CommandText = "<ldap://" & ConfigNC _ & ">;(objectClass=nTDSDSA);AdsPath;subtree" ' END CALLOUT B Command.Properties("Cache Results") = False Command.Properties("Page Size") = 100 Command.Properties("Sort On") = "CN" Command.Properties("Timeout") = 30 Set RecordSet = Command.Execute() ' CALLOUT C Do While Not RecordSet.EOF Set DC = GetObject(GetObject(RecordSet.Fields("AdsPath").Value).Parent) WScript.Echo DC.CN RecordSet.MoveNext() Loop ' END CALLOUT C Connection.Close() |
Lists Domain Controllers
Posted by John Sorensen on June 13th, 2009
Further Reading
- None Found


Posted in