Link to home
Start Free TrialLog in
Avatar of techdrive
techdriveFlag for United States of America

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.FileSystemObject")
Set objFile = objFSO.CreateTextFile("c:\output.txt", True)
On Error Resume Next
 
Const ADS_SCOPE_SUBTREE = 2
 
dtmCreationDate = "20110909000000.0Z"
 
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand =   CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection
 
objCommand.Properties("Page Size") = 1000
objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE
 
objCommand.CommandText = _
    "SELECT Name, objectCategory, whenCreated FROM 'LDAP://cn=computers,dc=somedomain,dc=local' WHERE "  & _
        "whenCreated>='" & dtmCreationDate & "'"
Set objRecordSet = objCommand.Execute
 
objRecordSet.MoveFirst
Do Until objRecordSet.EOF
    Wscript.Echo objRecordSet.Fields("Name").Value
    Wscript.Echo objRecordSet.Fields("objectCategory").Value
    Wscript.Echo objRecordSet.Fields("whenCreated").Value
    objRecordSet.MoveNext
Loop
Avatar of RobSampson
RobSampson
Flag of Australia image

Hi, one way to do it is to run
cscript YourScript.vbs > Output.txt

Regards,

Rob.
ASKER CERTIFIED SOLUTION
Avatar of RobSampson
RobSampson
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial