Returns the name and location for all the computer accounts in Active Directory that are running Windows .NET Server.
Const ADS_SCOPE_SUBTREE = 2Set objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCommand.ActiveConnection = objConnectionobjCommand.CommandText = _"Select Name, Location, operatingSystemVersion from 'LDAP://DC=fabrikam,DC=com'" _& " where objectClass='computer' and operatingSystemVersion = '5.1 (3600)'"objCommand.Properties("Page Size") = 1000objCommand.Properties("Timeout") = 30objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREEobjCommand.Properties("Cache Results") = FalseSet objRecordSet = objCommand.ExecuteobjRecordSet.MoveFirstDo Until objRecordSet.EOFWscript.Echo "Computer Name: " & objRecordSet.Fields("Name").ValueWscript.Echo "Location: " & objRecordSet.Fields("Location").ValueobjRecordSet.MoveNextLoop
This is a VB Script, this can be used by saving the file in .vbs file