I am trying to write a PowerShell script to ping each IP Address from a CSV file 4 times. I know there are plenty of issues with this script, I am working and learning as I go. The one issue that has me stumped is when I run the script the $iplist variable takes the first variable and then runs through the list. I think it has to do with the array and the import-Csv, but I can't figure it out or break it well enough to get a clue.
Thank you
I omitted the full target location for security's sake
$iplist = @(Import-Csv "Book1.csv")
Write-Host $iplist
ForEach ($Data in $iplist)
{
Test-Connection $Data | Out-File Bookx.txt
}
When the contents of $iplist are Write-Host the following is displayed: @{151.171.77.24=151.171.175.132} @{151.171.77.24=151.171.175.131}
There are a few dozen that all have the same 151.171.77.24= please note that 151.171.77.24 is the first IP in Book1.csv