Active Directory: Get Last Logon Time For Users

Ever needed the logon time for users in your Active Directory domain? Use the following command:

For /F "Skip=1 Tokens=3" %I in ('Dsquery * domainroot -filter "(&(objectCategory=Person)(objectClass=User)(samaccountname=))" -attr name lastLogon') Do @w32tm /ntte %I

The above command runs the Dsquery command and pipes the output to the w32tm command to convert the integer timestamp to human readable form.