Last Logon Date of Machines

Posted on 2014-08-05
Last Modified: 2014-08-06
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!
Question by:Terellion
    LVL 22

    Expert Comment

    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)

    Author Comment

    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
    LVL 38

    Accepted Solution

    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


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    A post on a forum I visit frequently mobilized me to create a script to remove a password (the one required to open a file) from any number of Word files. Because nobody would want to open a 100 files and manually save them... Of course, you have t…
    Are you one of those front-line IT Service Desk staff fielding calls, replying to emails, all-the-while working to resolve end-user technological nightmares? I am! That's why I have put together this brief overview of tools and techniques I use in o…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now