i want to write PS script that reads computers from a CSV and checks time stap and export the result

i have a CSV that contains computer list and i want to write a PS script that reads the list and export the time stamp for the computer.
Debrata 1Asked:
Who is Participating?
 
Sajen JoseCommented:
I think the problem is with the FT (Format-Table) used in the above script inside the Foreach Loop. You may want to try removing / replacing the Format-Table in the pipeline

 $result +=Get-ADComputer $line.ComputerName -Properties * | FT Name, LastLogonDate

Open in new window


Format-Table transforms the object into formatting directives...
0
 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Define the term PS.

Postscript? Python Script? Photoshop?

If you're talking about Python (likely), then start with any Python tutorial.

Just open your file, loop through records, parse data, process data, output data.

If your .csv file is simple enough, you can post it + likely someone can assist.

You'll also have to define what you mean by export the time stamp for the computer.

Export to what? A file? Or maybe actually setting the time on one or all computers to be in sync. Unclear.

Expand your question + include your .csv file data + likely someone can assist.
0
 
Debrata 1Author Commented:
Sorry for not explaining enough i meant to say Powershell by PS. I can see the result of my script but i can't export it to CSV

Import-Module activedirectory
$csv = import-csv C:\Users\alif.mehari\Documents\computers.csv
$result = @()
foreach ($line in $csv)
{
    $result +=Get-ADComputer $line.ComputerName -Properties * | FT Name, LastLogonDate
}
0
On-Demand: Securing Your Wi-Fi for Summer Travel

Traveling this summer?Check out our on-demand webinar to learn about the importance of Wi-Fi security and 3 easy measures you can start taking immediately to protect your private data while using public Wi-Fi. Follow us today to learn more!

 
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Ah! Powershell!

Likely someone can point out how to fix your syntax... fairly quickly.
0
 
Debrata 1Author Commented:
This is not doing it either.

Import-Module activedirectory
$csv = import-csv C:\Users\alif.mehari\Documents\computers.csv
$result = @()
foreach ($line in $csv)
{
    $result +=Get-ADComputer $line.ComputerName -Properties * | FT Name, LastLogonDate
}
$result | Select-Object -Property Name, LastLogonDate |Export-Csv C:\Users\alif.mehari\Documents\OLD_Computer.csv -notypeinformation
0
 
PberSolutions ArchitectCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Accept: Sajen Jose (https:#a42424594)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Pber
Experts-Exchange Cleanup Volunteer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.