Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export Information

Status
Not open for further replies.

clayton74

Technical User
Apr 17, 2002
187
GB
Hello
I have a script that lists disabled users in AD, what I am after is to export the list into a text document
Can anybody help please


Const ADS_UF_ACCOUNTDISABLE = 2

Set objConnection = CreateObject("ADODB.Connection")
objConnection.Open "Provider=ADsDSOObject;"
Set objCommand = CreateObject("ADODB.Command")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"<GC://dc=corp,dc=ukrail,dc=net>;(objectCategory=User)" & _
";userAccountControl,distinguishedName;subtree"
Set objRecordSet = objCommand.Execute

intCounter = 0


Do Until objRecordset.EOF
intUAC=objRecordset.Fields("userAccountControl")
If intUAC AND ADS_UF_ACCOUNTDISABLE Then
WScript.echo objRecordset.Fields("distinguishedName") & " is disabled"
intCounter = intCounter + 1
End If
objRecordset.MoveNext
Loop

WScript.Echo VbCrLf & "A total of " & intCounter & " accounts are disabled."

objConnection.Close
 
you are wscript.echo'n
use this as your output.
so run your script somethign like

cscript.exe myscript.vbs > c:\output.txt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top