How to get Last Logon Time Stamp in Active Directory

How to get Last Logon Time Stamp in Active Directory

August 22, 2021 Active Directory PowerShell 0

How To Get Computer Last Logon Time Stamp Using PowerShell

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

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

 

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

Import Csv file and save them in Variable,

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

 

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

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

 

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

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

 1,362 total views,  1 views today

Leave a Reply

Your email address will not be published. Required fields are marked *