I inherited the job of archiving and deleting stale user accounts in out Windows 2003 AD. I was left the following script and I wanted to know exactly what the script is doing and is exporting its findings to a text file.
On Error Resume Next
Set colItems = GetObject("LDAP://OU=Users, OU=MYSITE, OU=Users, OU=Z - Sites, OU=MYORG, OU=SYSTEM, DC=system, DC=ic, DC=gov")
colItems.Filter = Array("User")
For Each objItem in colItems
set objLogon = objItem.Get("lastLogon")
intLogonTime = objLogon.HighPart * (2^32) + objLogon.LowPart
intLogonTime = intLogonTime / (60 * 10000000)
intLogonTime = intLogonTime / 1440 + #1/1/1601#
If intLogonTime < #1/1/2008# and intLogonTime > #1/1/1601# Then
WScript.Echo objItem.CN & ", " & intLogonTime
Else If intLogonTime = #1/1/1601# Then
WScript.Echo objItem.CN & " - User never logged on."