• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 434
  • Last Modified:

Last Logon Date of Machines

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!
0
Terellion
Asked:
Terellion
1 Solution
 
plusone3055Commented:
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)
http://gallery.technet.microsoft.com/scriptcenter/Get-Active-Directory-user-246f17c7
0
 
TerellionAuthor Commented:
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
0
 
footechCommented:
Assuming your .CSV looks like this.
Name
comp1
comp2

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 $_.name -Properties LastLogonDate
} | Select Name,LastLogonDate |
 Export-CSV output.csv -notype

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now