#gets the file location/file name of the IP address
Param($addr)
$file = Get-Content $addr
$i = 0
while ($i -ne $file.Count) {
Write-Host $file
$i++
}
Output:
8.8.8.8 127.0.0.1 208.67.222.222 8.8.8.8 127.0.0.1 208.67.222.222 8.8.8.8 127.0.0.1 208.67.222.222
File content:
8.8.8.8 127.0.0.1 208.67.222.222
I only want it to iterate and print out one line, not all three lines on a single line 3 times. I need this so I can run a ping command on each address.
write-host $file. So the simple fix would be to$file[$i]. But you could be using different loop structures alltogether.get-content $addr | Foreach-Object{ "do something with $_"}