List Last Logon Time for Active Directory

Argomenti vari di carattere sistemistico
Post Reply
daniele
Posts: 342
Joined: 04 Mar 2009, 13:59

List Last Logon Time for Active Directory

Post by daniele »

  • Copiare il testo seguente in un file
  • Sostituite NOME_DOMINIO e NOME_SERVER con i nomi appropriati
  • Salvare il file con estensione .VBS (es. LastLogonTime.VBS).
  • Eseguire il comando CSCRIPT LASTLOGONTIME.VBS

Code: Select all

' List last logon times
' 2001-03-27 John Savill, Jakob Hussfelt http://www.ntfaq.com
On Error Resume Next
sEnterDCs = "NOME_DOMINIO,NOME_SERVER"
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

Questo script interroga solamente il Primary Domain Controller
Post Reply