Get Last Logon Date for All Active Directory Users

Published: 13 July 2023
on channel: Active Directory Pro
8,170
30

In this video, you will learn how to get the last logon date for all Active Directory users.

The Active Directory last logon date is stored in the lastlogon attribute for each user account. The lastlogon attribute is updated when a user authenticated to the network. It is updated on the domain controller the user authenticates to and is not replicated. To create an accurate last logon report you will need to get the lastlogon attribute from all domain controllers for all users.

The lastLogonTimestamp attribute should not be used to create a last logon report as it has a delay in the value. This lastLogonTimestamp was designed by Microsoft to find inactive users not for creating last logon reports.

With the AD Pro Toolkit, you can easily get all users last logon date and create accurate reports for auditing and security needs. The report can easily be exported to to CSV, Excel or PDF. Click on the Last Logon Report and click run, it is that easy (all the calculations is done in the background). Use the filter option to find the last logon date in the last 90 days, 30 days or custom time period.

With PowerShell you can use the following command to get the last logon date for a single user. Again this will get the lastlogon value from a single domain controller, you will need to run this on all DCs to get an accurate report.

Single user:
Get-ADUser -filter * -Properties Name,LastLogon | Select-Object Name,Manager,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}

Get last logon date for all users:
Get-ADUser -filter * -Properties Name,LastLogon | Select-Object Name,Manager,@{n='LastLogon';e={[DateTime]::FromFileTime($_.LastLogon)}}

Download Free Trial of AD Pro Toolkit:
https://activedirectorypro.com/downlo...

Learn More:
https://activedirectorypro.com/report...

Follow me on Twitter!
  / adpro99  


Watch video Get Last Logon Date for All Active Directory Users online without registration, duration hours minute second in high quality. This video was added by user Active Directory Pro 13 July 2023, don't forget to share it with your friends and acquaintances, it has been viewed on our site 8,170 once and liked it 30 people.