Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Last Login Times - User and Computers 2

Status
Not open for further replies.

amajacma

MIS
Mar 22, 2005
1
US
Is there a way to find out the last time when a computer or a user was logged onto the system? We have Windows 2000 Server and Windows 2000 desktops.

Thanks!

Annie
 
For local user
net user username

For domain user
net user username /domain

===
Karlis
ECDL; MCP
 
You could also take a look at the vbscript section. There are a lot of answer to your question.

Patrick
 
In a Windows 2000 domain, you would need to poll every domain controller to be sure you have the right information. In Windows 2003 this is replicated by default.

Also, remember that if a user walks away and LOCKS their desktop, this does not reset the last logon time then next time the user returns and UNLOCKS their destkop.
 
I have used the following script from Winnt Magazine to do this:

Save the following text into file userlogin.vbs

' List last logon times
' 2001-03-27 John Savill, Jakob Hussfelt On Error Resume Next
sEnterDCs = "SAVILLTECH,SAVILLNT02"
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

In line 'set oDomain = GetObject("WinNT://SAVILLTECH")' you should change SAVILLTECH to your domain name.

To run type the following:

C:\> cscript userlogin.vbs

Below is a sample output:

C:\>cscript d:\temp\disuser.vbs
Microsoft (R) Windows Scripting Host Version 5.0 for Windows
Copyright (C) Microsoft Corporation 1996-1997. All rights reserved.

Domain : SAVILLTECH
Full Name=Maria Aala (DIS 120 inactive)Last login=27/05/1999 14:44:24
Full Name=Paul J AaronLast login=16/08/1999 13:01:56
Full Name=Hany A AbbasLast login=23/08/1999 13:25:46
Full Name=Tony S AbbittLast login=27/08/1999 15:07:20
Full Name=Adnan AbdallahLast login=16/07/1999 10:34:58
Full Name=Tony AbelaLast login=21/07/1999 10:43:20
Full Name=Juan Claudio AbelloLast login=25/06/1999 11:15:32
Full Name=Marie J B AbreyLast login=07/09/1999 08:00:34
Full Name=Philippa AbsilLast login=07/09/1999 06:33:18
Full Name=Ace Test account for NetID - Alistair PurvisLast login=28/01/1999 07:5
4:30
Full Name=Chris AckermannLast login=07/09/1999 08:21:20
Full Name=Curtis S AdamsLast login=10/08/1999 12:32:02
Full Name=Helen R Adams DIS user left 27.8.99Last login=02/08/1999 08:52:58
Full Name=Michael Adams Dis 4.6.99 NMFLast login=03/06/1999 08:50:10
Full Name=Philip R AdamsLast login=14/06/1999 12:49:00


You can also use USRSTAT.EXE from the resource kit.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top