Last Logon Date of Machines

Terellion used Ask the Experts™
Hi there, I have a list of machines in a CSV and i'd like to import the CSV into powershell and then add a column with a list of last logon dates from Active Directory for these machines and output to a new file. Is this possible?

Thanks so much!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Here is a step by step tutorial for what you are asking for with visual aids and code :)
Get Active Directory user account last logged on time (PowerShell)


Hi there, thats for user accounts :( Please assist with this, i tried importing them using that link but it said they all didn't exist even though they do. Thanks
Top Expert 2014
Assuming your .CSV looks like this.

Open in new window

Tip for the future - if you only have one column, leave out the header and just have a simple text file rather than a .CSV.

This should work.
Import-Module ActiveDirectory
Import-CSV input.csv | ForEach `
    Get-ADComputer $ -Properties LastLogonDate
} | Select Name,LastLogonDate |
 Export-CSV output.csv -notype

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial