How do you find out the last log-in time for a windows machine(any user) through powershell?
+1
A:
It's apparently non-trivial when you involve domain controllers. Here's the code ripped from that blog entry (first one on google, by the way)
Without a Domain Controller:
(Get-QADUser username).lastLogon
With:
Get-QADComputer -ComputerRole
DomainController | foreach {
(Get-QADUser -Service $_.Name
-SamAccountName username).LastLogon.Value } |
Measure-Latest
Tom Ritter
2009-08-13 14:26:20
Thanks Tom Ritter. I saw that one too before raising this question on SO. But my question is about last login time for any user on a machine (I'm not concerned about one particular user)
BlueGene
2009-08-13 15:09:46