Quantcast
Channel: PowerShell.com – PowerShell Scripts, Tips, Forums, and Resources
Viewing all articles
Browse latest Browse all 6937

Export selected column from a CSV to a text based on a value in the CSV

$
0
0

Hi all, thanks in advance for your assistance.

I am working on a powershell script that will disable servers that have not been logged onto in 180 days and do not respond to pings.  Right now I am at a crossroads, I have a CSV file that has 6 columns: NameInList, NameFromDNS, IPAddressListFromDNS, SuccessPercentage, LastPingStatus, and Pinged From.  What I want to do is take any ComputerNames (NameInList) that showed a 0 for SuccessPercentage and create a txt file named ServersToDelete.txt.  This is what I have so far:

import-csv .\PingResults.csv | foreach-object { $_.NameInList } | sort-object -unique | out-file .\ServersToDisable.txt

I am able to create a text file from the CSV with the Computer Names but am not sure of how to only get computer names whose Ping Success Percentage was 0.

Any advice is greatly appreciated.

Best Regards,

Ed

 


Viewing all articles
Browse latest Browse all 6937

Trending Articles