PowerShell: Find Computers Last Logon Date

KB ID 0001612

Problem

I had to find the last time a particular server had logged on for a client the other week, so we knew for sure it was dead!

Solution

The two commands you may need are;

Locate Servers Last Login Time

[box]

Get-ADComputer -Filter {OperatingSystem -Like '*SERVER'} -Properties lastlogondate,operatingsystem | Select name,laslogondate,operatingsystem

[/box]

Locate Clients Last Login Time

[box]

Get-ADComputer -Filter {OperatingSystem -notLike '*SERVER'} -Properties lastlogondate,operatingsystem | Select name,laslogondate,operatingsystem

[/box]

Short and sweet!

Related Articles, References, Credits, or External Links

NA