top of page

How to get Computer LastLogonTime Stamp using PowerShell

It is simple to get the Lastlogon time stamps for the computers using Active Directory Snap-in or importing the Active Directory module in the Normal PowerShell

For one Computer,

Open Active Directory Snap-in and run the below command with computer name for which you want to fetch the lastlogon time stamp


Get-ADComputer -Identity ComputerName -Properties * |select name, LastLogonDate


Get-ADComputer  -Identity Computer1 -Properties * |select Name, LastLogonDate

Name                                         LastLogonDate —-                                                ————- Computer1                                      2017-05-25 01:12:53

Now, let see how to get it for bulk servers.

First up all, We need to take the computers list and save it as Csv file with  Header:Name

Command 1:

Import Csv file and save them in Variable,

$Computer = Import-Csv -path “C:\files\computers.csv”

Command 2:

Use the below command to get the last logon time stamp for the bulk computers,

$Computer| foreach{Get-ADComputer -Identity $ -Properties * |select name, LastLogonDate}

Command 3:

You can even export the output to Csv using the below command.

$Computer| foreach{Get-ADComputer -Identity $ -Properties * |select name, LastLogonDate} | Export-Csv output.csv -NoTypeInformation

3 views0 comments


bottom of page