Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 681

Sort By VB Script Possible?

$
0
0
Hi,

This is my code and basically i want to sort it by Last Login can I do that with my current code and if so can someone point me in the right direction - I'm still learning and this is sort of just a personal project.

' List last logon times

On Error Resume Next

' \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' \\\\\\Enter Domain Controller
' \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

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

Viewing all articles
Browse latest Browse all 681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>