I wanted to check to see what AD accounts i could delete. Sometimes HR doesn't tell me when PT employees leave. I found this script.
' List last logon times
On Error Resume Next
sEnterDCs = "DOMAINCONTROLLER"
sObjects = Split(sEnterDCs, ",")
Set oDomain = GetObject("WinNT://" & sObjects(0))
oDomain.Filter = Array("User")
WScript.Echo "Showing last login times of accounts from: " & oDomain.Name & vbNewLine
For Each oDomainItem In oDomain
sUsrLogin = oDomainItem.LastLogin
If UBound(sObjects) >= 1 Then
For ii = 1 To UBound(sObjects)
Set oUsr = GetObject("WinNT://" & sObjects(ii) & "/" & oDomainItem.Name & ",user")
If oUsr.LastLogin > sUsrLogin Then sUsrLogin = oUsr.LastLogin
Next
End If
WScript.Echo "Username: " & Left(oDomainItem.Name & Space(22),22) & "Last login: " & FormatDateTime(sUsrLogin)
Next
Well the issue is there are lastlogintimes on accounts in the past few weeks i know have not been accessed in a year or so. What could be doing this? Is it my Backup or antivirus software? is is Exchange? We run W2k8 as our forest level and Exchange 2010. Thanks.