Is there any way to take the script below and feed information to 'strSearchFor' from a text file?
to search for, in order:
bla
bla1
bla2
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
strSearchFor = "BLA"
objCommand.CommandText = _
"Select Name, Location from 'LDAP://ou=subouname,ou=ouname,dc=owfg,dc=com' " _
& "Where objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
''''''''''''''''''''''''''
'Create and open dest file
''''''''''''''''''''''''''
strWriteFile = WSHShell.CurrentDirectory & "\" & strSearchFor & ".txt"
Set CreateFile = oFSO.CreateTextFile(strWriteFile, True)
CreateFile.Close
Set strWriteFile = oFSO.OpenTextFile(strWriteFile, ForWriting)
'''''''''''''''
'Write to file
'''''''''''''''
Do Until objRecordSet.EOF
strComputerName = objRecordSet.Fields("Name").Value
If inStr(1, strComputerName, strSearchFor, vbTextCompare) Then strWriteFile.WriteLine _
(strComputerName)
objRecordSet.MoveNext
Loop
to search for, in order:
bla
bla1
bla2
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Set WSHShell = WScript.CreateObject("WScript.Shell")
Set oFSO = WScript.CreateObject("Scripting.FileSystemObject")
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
strSearchFor = "BLA"
objCommand.CommandText = _
"Select Name, Location from 'LDAP://ou=subouname,ou=ouname,dc=owfg,dc=com' " _
& "Where objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
''''''''''''''''''''''''''
'Create and open dest file
''''''''''''''''''''''''''
strWriteFile = WSHShell.CurrentDirectory & "\" & strSearchFor & ".txt"
Set CreateFile = oFSO.CreateTextFile(strWriteFile, True)
CreateFile.Close
Set strWriteFile = oFSO.OpenTextFile(strWriteFile, ForWriting)
'''''''''''''''
'Write to file
'''''''''''''''
Do Until objRecordSet.EOF
strComputerName = objRecordSet.Fields("Name").Value
If inStr(1, strComputerName, strSearchFor, vbTextCompare) Then strWriteFile.WriteLine _
(strComputerName)
objRecordSet.MoveNext
Loop