Listing 1: GetListOfComputers ' BEGIN COMMENT ' This script outputs a list of all the computers in your domain. ' The only thing you need to modify is the value of yourDomain. ' Replace LDAP://DC=montereytechgroup,DC=com with the ' LDAP name of your domain. ' END COMMENT Set yourDomain="'LDAP://DC=montereytechgroup,DC=com' Const ADS_SCOPE_SUBTREE = 2 ' BEGIN COMMENT ' Connect to Active Directory. ' END COMMENT Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Provider = "ADsDSOObject" objConnection.Open "Active Directory Provider" ' BEGIN COMMENT ' Create a query for all computers in the domain. ' END COMMENT Set objCommand.ActiveConnection = objConnection objCommand.CommandText = _ "Select cn from " & _ yourDomain where objectClass='computer'" objCommand.Properties("Page Size") = 1000 objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE Set objRecordSet = objCommand.Execute objRecordSet.MoveFirst ' BEGIN COMMENT ' Loop though all computers in the domain. ' END COMMENT Do Until objRecordSet.EOF ' BEGIN COMMENT ' Write each computer name out to the file. ' END COMMENT Wscript.Echo objRecordSet.Fields("cn").Value objRecordSet.MoveNext Loop