I have a PowerShell loop that does effectively what I want it to. The problem is that the output is very messy. I work for an ISP and one of the most effective ways we have to diagnose network issues is via multiple pings.
The problem is that setting up multiple pings can be messy. Rather than trying to reinvent the wheel, I'm seeking to create a simple PowerShell script that will provide an easy to digest output based on a list of IP addresses.
Here is the code I currently have:
# Define a list of IP addresses and hostnames to ping
$targets = Get-Content -Path C:\Users\Chad\Desktop\IPs.txt
# Loop through each target and ping it
while (1) {
foreach ($target in $targets) {
ping $target -n 1
}
}
I won't say my code is particularly elegant or groundbreaking. All I need to know is if there is a way to export the results for the pings to a .csv where each column represents one IP address, and the rows represent the latency for each particular ping.
The idea is that I can train my peers on how to use this script and that the .csv will not be opened until the pings are manually stopped. I'm fully open to completely reformulating how I am approaching this problem as well.
Any help is appreciated!