I am testing querying AD for some information. Here, I want the code to echo if it finds my machine name in the domain.

I created this in a notepad (changed the values in the code according to my domain and machine name and saved it as a .vbs file). Went to the command prompt and ran the .vbs file. IT comes back with this error:

C:\WINDOWS>cscript c:\temp\vbtest.vbs
Microsoft (R) Windows Script Host Version 5.6
Copyright (C) Microsoft Corporation 1996-2001. All rights reserved.

c:\temp\vbtest.vbs(22, 4) Microsoft VBScript compilation error: Expected stateme

### Code below ##

Option Explicit

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"

Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection

objCommand.CommandText = _
"<LDAP://dc=mysecondarydomain,dc=myprimary domain,dc=com>;(objectCategory=computer)" & _

Set objRecordSet = objCommand.Execute

While Not objRecordSet.EOF

If objRecordSet.Fields("Name") = "mymachinename" Then
Wscript.Echo objRecordSet.Fields("Name")
Wscript.Echo "[" & objRecordSet.Fields("distinguishedName") & "]"

0 Comments   [ + ] Show Comments


Please log in to comment

Rating comments in this legacy AppDeploy message board thread won't reorder them,
so that the conversation will remain readable.


I belive you would need a space between your End IF
Answered 01/21/2005 by: TomB
Orange Belt

Please log in to comment
Your right...you need a space between END and IF
Answered 02/18/2005 by: strakm
Senior Yellow Belt

Please log in to comment
Answer this question or Comment on this question for clarity