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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Ah! Powershell!

Likely someone can point out how to fix your syntax... fairly quickly.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.