Solved Do Until EOF will not finish

September 17, 2012 at 22:01:43
Specs: Windows 7
I have wrote a script to detect computers in AD that have a PasswordLastChange > 90 days
however the script will not finish. it just keeps running in task manager, im not sure as to why.
I am getting results in my output file.

Code is as follows

On Error Resume Next

'Creating Log Files File
dim filesys, outputfile
set filesys = CreateObject("Scripting.FileSystemObject")
set outputfile=filesys.createtextfile("pwdLastSet.csv",true)

'Get Current Domain
Set objRootDSE = GetObject("LDAP://RootDSE")
strDNSDomain = objRootDSE.Get("DefaultNamingContext")

'Collecting to Domain
Set objConnection = CreateObject("ADODB.Connection")
Set objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open "Active Directory Provider"
Set objCommand.ActiveConnection = objConnection

objCommand.CommandText = "<LDAP://" & strDNSDomain & ">;" & "(&(ObjectCategory=Computer))" & ";" & "name, distinguishedName" & ";SubTree"

'Executing Command + filters
Set objRecordSet = objCommand.Execute


'Reading Record Sets
objRecordSet.MoveFirst
outputfile.writeline "Node Name" & "," & "Days Since Last Change" & "," & "Date Last Changed"
Do Until objRecordSet.EOF
Set ldapName = GetObject("LDAP://" & objRecordSet.Fields("distinguishedName").value & "")
LPD = ldapName.PasswordLastChanged
LPDDiff = Datediff("D", LPD, Now)
If (LPDDiff > 90) Then
outputfile.writeline objRecordSet.Fields("Name").Value & "," & LPDDiff & "," & ldapName.PasswordLastChanged
End iF

objRecordSet.MoveNext
Loop
wscript.echo "Script Completed"


See More: Do Until EOF will not finish

Report •

#1
September 17, 2012 at 22:04:38
More information.

I have remove "On Error Resume Next"
i get a message that indicates "The size Limit for this request was exceeded"


Report •

#2
September 18, 2012 at 01:15:02
✔ Best Answer
Try adding the line:

objCommand.Properties("Page Size") = 1000

just before the 'Executing Command comment.

edited by moderator: No response from the OP, setting this as BA -Razor2.3


Report •
Related Solutions


Ask Question