Microsoft
Software
Hardware
Network
Question : create log from a cscript ran file
Guys
I am needing to run this script using CSCRIPT but need the results to be created in a log file
can anyone help
On Error Resume Next
Const ADS_SCOPE_SUBTREE = 2
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 FROM 'LDAP://dc=fabrikam,dc=com
' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
Wscript.Echo objRecordSet.RecordCount
Cheers
Darren
Answer : create log from a cscript ran file
This will create the output file "ADComputerList.txt" in the same folder where the script is called from. If you want a specific path, just enter the full path of the file.
'---------BEGIN
Const ForReading = 1, ForWriting = 2, ForAppending = 8
Const ADS_SCOPE_SUBTREE = 2
On Error Resume Next
Set fso = CreateObject("Scripting.Fi
leSystemOb
ject")
Set objResults = fso.CreateTextFile("ADComp
uterList.t
xt", ForWriting)
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 FROM 'LDAP://dc=fabrikam,dc=com
' WHERE objectCategory='computer'"
Set objRecordSet = objCommand.Execute
objResults.writeline objRecordSet.RecordCount
-TM
Random Solutions
Adobe Acrobat 7.0 for Macintosh
Image Deployment - Altiris
language property reporting services
Outlook 2007 error
Domino Clusters
Add Network Driver to Ghost 10 ISO file
Exchange Problems
Vista firewall - switch on and off? from a command prompt?
Microsoft, Windows, XP, DHCP Ping Issues
Slow Accpac running on SQL on a new fresh install of server 2003 and sql and acpac?