'========================================================================== ' ' VBScript: AUTHOR: Ed Wilson , MS, 7/1/2006 ' ' NAME: ' ' COMMENT: Key concepts are listed below: '1.Main thing here is to do a multiple filter. Must use the '2.(&(objectCategory=user)(location=Atlanta)) syntax. '3. The location attribute applies to computer. And can be set On '4. the location tab in ADUC. '========================================================================== Option Explicit On Error Resume Next dim strQuery dim objConnection dim objCommand dim objRecordSet strQuery = ";" & _ "(&(objectCategory=computer)(name=MyNewComputer))"&_ ";name,location,distinguishedname;subtree" Set objConnection = CreateObject("ADODB.Connection") Set objCommand = CreateObject("ADODB.Command") objConnection.Open "Provider=ADsDSOObject;" objCommand.ActiveConnection = objConnection objCommand.CommandText = strQuery Set objRecordSet = objCommand.Execute Do until objRecordSet.EOF WScript.echo ForMatTxt("Computer named: " & objRecordSet("name")) &_ objRecordSet.Fields("name") & " is located: " & objRecordSet.Fields("location") &_ vbcrlf & "Distinguished name: " & objRecordSet.fields("distinguishedname") objrecordset.MoveNext Loop Function ForMatTxt(lineOfText) Dim numEQs Dim separator Dim i numEQs = Len(lineOfText) For i = 1 To numEQs separator = separator & "=" Next ForMatTxt = lineOfText & vbcrlf &separator & vbcrlf End Function