Get List Of Active Directory Users With Their Last Logon Date

Support: 877.727.7978 Sales: 888.897.6270 Crestline IT Services HamBurger Close Icon
Active Directory Get List of Active Directory users with their Last Logon Date June 03, 2020

Get a list of active users is pretty trivial with powershell, however with multiple AD controllers, things become more complicated. There are effective two fields LastLogon and LastLogonTimestamp. Depending on replication and AD server, the values may be different.

The following Powershell script will query each ADC and get the most recent login date:

https://github.com/CrestlineIT/PowerShellSnippets/blob/master/ADUserLastLogon.ps1

To export the list in CSV, simply use it like this:

ADUserLastLogon.ps1 | Export-CSV -Path "C:\temp\ADUsers.csv" -NoTypeInformation

For more information about each attribute, see below:

lastLogon

This attribute is not replicated and is maintained separately on each domain controller in the domain. To get an accurate value for the user’s last logon in the domain, the Last-Logon attribute for the user must be retrieved from every domain controller in the domain. The largest value that is retrieved is the true last logon time for that user.

https://docs.microsoft.com/en-us/windows/desktop/adschema/a-lastlogon lastLogonTimestamp

Whenever a user logs on, the value of this attribute is read from the DC. If the value is older [ current_time – msDS-LogonTimeSyncInterval ], the value is updated. The initial update after the raise of the domain functional level is calculated as 14 days minus random percentage of 5 days.

https://docs.microsoft.com/en-us/windows/desktop/adschema/a-lastlogontimestamp

Related articles

IT careers in Ottawa, ON

General

IT Careers in Ottawa: Education That Opens Doors in Tech

February 16, 2026

Blog

Benefits of Managed IT Services: Protect Your Business, Cut Costs & Grow Smarter

January 20, 2026

top-10-tips-to-stay-safe-online

Blog

Digital Armor: Top 10 Tips for Protecting Yourself Online

February 06, 2025

Do you need IT, cybersecurity or software development services?

Discover Crestline IT, a trusted Canadian IT company based in Toronto, Ontario.

Discover Crestline IT × ×

Tag » Active Directory Get List Of Computer Last Logon Date