Getting Last Logon Information With PowerShell
Recently I had to write a report that got the last logon date for all of our users and I really ran into the LastLogonDate problem. What problem is that, you might ask? Well, it’s been documented a lot but the root of the problem is when a user logs into a domain account, their login time is recorded into the lastLogon field in Active Directory on the domain controller they authenticated against. This field is stored as FileTime, which is the date and time as a 64-bit value in little-endian order representing the number of 100-nanosecond intervals elapsed since January 1, 1601 (UTC). And just to make it a little bit more fun Active Directory does not replicate it. So if someone logs in in India, and you query your Active Directory Domain Controller here in Massachusetts you will NOT get the updated information. So now what?