bbbngowc Posted May 13, 2009 Posted May 13, 2009 I have this Windows Script and would like to output it to a text file. Can someone show me how that's done please?Const ADS_SCOPE_SUBTREE = 2Set objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCommand.ActiveConnection = objConnectionobjCommand.Properties("Page Size") = 1000objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT Name FROM 'LDAP://dc=btcbahamas,dc=com' WHERE objectCategory='user' " & _ "AND msNPAllowDialin = TRUE"Set objRecordSet = objCommand.ExecuteobjRecordSet.MoveFirstDo Until objRecordSet.EOF Wscript.Echo objRecordSet.Fields("Name").Value objRecordSet.MoveNextLoop
gunsmokingman Posted May 14, 2009 Posted May 14, 2009 This will make a text file called Text_Report.txt in the folder where the script is.Const ADS_SCOPE_SUBTREE = 2Dim Fso :Set Fso = CreateObject("Scripting.FileSystemObject")Set objConnection = CreateObject("ADODB.Connection")Set objCommand = CreateObject("ADODB.Command")objConnection.Provider = "ADsDSOObject"objConnection.Open "Active Directory Provider"Set objCommand.ActiveConnection = objConnectionobjCommand.Properties("Page Size") = 1000objCommand.Properties("Searchscope") = ADS_SCOPE_SUBTREE objCommand.CommandText = _ "SELECT Name FROM 'LDAP://dc=btcbahamas,dc=com' WHERE objectCategory='user' " & _ "AND msNPAllowDialin = TRUE"Set objRecordSet = objCommand.ExecuteDim Ts Set Ts = Fso.CreateTextFile("Text_Report.txt") Ts.WriteLine Now objRecordSet.MoveFirst Do Until objRecordSet.EOF Ts.WriteLine objRecordSet.Fields("Name").Value Wscript.Echo objRecordSet.Fields("Name").Value objRecordSet.MoveNext Loop Ts.Close
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now