I have attached the script as a txt file.
I uncommented the line that Al said but I'm still getting a error on
line 13,1
Set objComputer = GetObject(adoRecordset.Fields.Item("ADSPath"))
Const ForReading = 1, ForWriting = 2, ForAppending = 8
wscript.echo "The script has started"
strhost= "dhjc28l21"
'Create the output file
set fileSys = CreateObject("Scripting.FileSystemObject")
Set fileTxt = fileSys.OpenTextFile("machine_Path.txt", ForWriting, True)
fileTxt.Writeline("Computer Name" & vbTab & "DN")
Set objDSE = GetObject("LDAP://rootDSE")
Set objComputer = GetObject(adoRecordset.Fields.Item("ADSPath"))
strLDAPPath = objDSE.Get("defaultNamingContext")
Set objCommand = CreateObject("ADODB.Command")
Set objConnection = CreateObject("ADODB.Connection")
objConnection.Provider = "ADSDSOObject"
objConnection.Open "Active Directory Provider"
objCommand.ActiveConnection = objConnection
strBase = "<LDAP://" & strLDAPPath & ">"
strFilter = "(&(objectClass=user)(objectCategory=computer)(name=" & strhost & "))"
strAttributes = "name,ADsPath"
strQuery = strBase & ";" & strFilter & ";" & strAttributes & ";subtree"
objCommand.CommandText = strQuery
objCommand.Properties("Page Size") = 100
objCommand.Properties("Timeout") = 30
objCommand.Properties("Cache Results") = False
objCommand.Properties("Size Limit") = 1000
Set adoRecordset = objCommand.Execute
While NOT adoRecordset.EOF
fileTxt.WriteLine(adoRecordset.Fields.Item("name") & vbTab &
adoRecordset.Fields.Item("ADSPath"))
adoRecordset.MoveNext
Wend
wscript.echo "End of Script"