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 | ' Run this script via cscipt other wise edit to direct output to text file ' ListComputers.vbs Dim RootDSE, DomainNC, Connection, Command, RecordSet ' CALLOUT A Set RootDSE = GetObject("LDAP://rootDSE") DomainNC = RootDSE.Get("defaultNamingContext") ' 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://" & DomainNC _ & ">;(objectCategory=Computer);CN;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 WScript.Echo RecordSet.Fields("CN").Value RecordSet.MoveNext() Loop ' END CALLOUT C Connection.Close() |
List all computers in Domain
Posted by John Sorensen on June 14th, 2009
Further Reading
- None Found


Posted in
Ridiculous quest there. What occurred after? Thanks!