How to Find a User's Last Logon Time on a Workstation

In this Guide:

Tracking the last logon time of a user on a workstation can be crucial for system auditing, troubleshooting, and monitoring inactive accounts. Windows provides multiple methods to check the last logon time, including Event Viewer, PowerShell, and third-party tools.


Why Check the Last Logon Time?

  • Monitor user activity and login patterns in the organization network. 
  • To identify and disable inactive or unused accounts to improve security.
  • Detect unauthorized access or unusual login behavior.
  • Ensure compliance with security and auditing policies.
  • Optimize resource allocation and account management. 

Methods to Check a User's Last Logon Time

1. Using Event Viewer

Event Viewer logs all login attempts, making it a reliable source for tracking logon times.

Steps:

  1. Press Windows + R, type eventvwr, and press Enter.
  2. Navigate to Windows Logs > Security.
  3. Look for Event ID 4624 (successful logon).
  4. Check the Logon Type to identify workstation logons:
    • Logon Type 2: Interactive logon (physical login).
    • Logon Type 10: Remote desktop session.

2. Using PowerShell

PowerShell offers an efficient way to retrieve a user's last logon time.

Command:

Get-EventLog -LogName Security -InstanceId 4624 |
Where-Object { $_.ReplacementStrings[5] -eq "USERNAME" } |
Select-Object TimeGenerated -First 1

Replace USERNAME with the user's login name to filter the log entries.

3. Using Command Prompt with Net User

The net user command provides basic details, including the last logon time.

Steps:

  1. Open Command Prompt as Administrator.

  2. Run the command:

    net user USERNAME
    
  3. Look for the Last Logon field in the output.

4. Using Active Directory for Domain Users

For domain accounts, you can retrieve the last logon time from the domain controller using PowerShell.

Command:

Get-ADUser -Identity USERNAME -Properties LastLogonDate

This command retrieves the last logon date directly from Active Directory.


Best Practices

  • Regularly review logon times to identify inactive or compromised accounts.
  • Enable and configure auditing policies to log all successful and failed logon events.
  • Use PowerShell scripts to automate logon activity reporting, especially in large environments.
  • Set up alerts for unusual login patterns to enhance security.
  • Archive old log data periodically to maintain system performance while keeping records.

Related Articles

Frequently asked questions: