techdrive
asked on
output data to a file
I am trying to save the out put of this script to a text file but its displaying to the screen. I tried to modify the echo statements but its not working after i modify this. Can someone help me here is what I have. I am wondering what am I doing wrong.
Set objFSO = CreateObject("Scripting.Fi leSystemOb ject")
Set objFile = objFSO.CreateTextFile("c:\ output.txt ", True)
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
dtmCreationDate = "20110909000000.0Z"
Set objConnection = CreateObject("ADODB.Connec tion")
Set objCommand = CreateObject("ADODB.Comman d")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnectio n = objConnection
objCommand.Properties("Pag e Size") = 1000
objCommand.Properties("Sea rchscope") = ADS_SCOPE_SUBTREE
objCommand.CommandText = _
"SELECT Name, objectCategory, whenCreated FROM 'LDAP://cn=computers,dc=so medomain,d c=local' WHERE " & _
"whenCreated>='" & dtmCreationDate & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name" ).Value
Wscript.Echo objRecordSet.Fields("objec tCategory" ).Value
Wscript.Echo objRecordSet.Fields("whenC reated").V alue
objRecordSet.MoveNext
Loop
Set objFSO = CreateObject("Scripting.Fi
Set objFile = objFSO.CreateTextFile("c:\
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
dtmCreationDate = "20110909000000.0Z"
Set objConnection = CreateObject("ADODB.Connec
Set objCommand = CreateObject("ADODB.Comman
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnectio
objCommand.Properties("Pag
objCommand.Properties("Sea
objCommand.CommandText = _
"SELECT Name, objectCategory, whenCreated FROM 'LDAP://cn=computers,dc=so
"whenCreated>='" & dtmCreationDate & "'"
Set objRecordSet = objCommand.Execute
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
Wscript.Echo objRecordSet.Fields("Name"
Wscript.Echo objRecordSet.Fields("objec
Wscript.Echo objRecordSet.Fields("whenC
objRecordSet.MoveNext
Loop
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
cscript YourScript.vbs > Output.txt
Regards,
Rob.