Active Directory (Windows Server 2012): User’s Last Login Data

NetAdmin’s gets tired of the request from operations to get the last logon time for a particular user time and time again. And the job is sometimes tiresome and monotonous. Network Administrator’s normally uses the “lastlogontimestamp” on daily basis to achieve a solution to this request. This only states the inactive users, and the data it will gather will be in a form of half a month old, reason why this attribute cannot be used to identify the last logon date and time for active users.

To identify the exact Last Logon date and time of an Active Directory user (preferably on Windows Server 2012 & Windows Server 2008 R2), you will need to connect to each DC in the user domain and extract the value of lastlogon attribute of that particular user account. Compare and keep only the highest one as it represents the last logon date and time.

This process will also become tiresome, if you are in a large AD environment, reason why the script is being developed where this script will automatically extract the lastlogon attribute from the domain controller and will highlight you the latest logon time for a given user. Only adjustment you need to do is to replace the domain name with your company domain name. This script will then ask of you the domain account name, which should be in accordance to the samaccountname.

Effected Operating Systems: Windows Server 2012 & Windows Server 2008 R2

Note: I got this script from the Internet, original username is still intact, just give him credit folks. Click HERE for the code