I am using Psping to check the latency of IPs with port and export the result CSV without display the header.
I have tried -select skip 1 it seems not working but with errors.
function CheckLatency
{
param([string[]]$servers)
foreach ($server in $servers)
{
$times = [ordered]@{ Server = "$server";TimeStamp = (Get-Date -f "yyyy-MM-dd hh:mm:ss"); Minimum = 0; Maximum = 0; Average = 0; }
$results = & "c:\users\test\desktop\psping.exe" -n 1 $server 2>&1 | select-string "Minimum"
if ($results) {
$results = $results.tostring() -split ","
foreach ($result in $results)
{
$result = ($result -replace "ms","").trim()
$parsed = $result -split " "
switch ($parsed[0])
{
"Minimum" {$times.Minimum = $parsed[2]}
"Maximum" {$times.Maximum = $parsed[2]}
"Average" {$times.Average = $parsed[2]}
}
}
new-object -type PSObject -prop $times
}
}
}
$csvFile = "C:\users\test\desktop\check$(get-date -f yyyy-MM-dd-hhmmss).csv"
CheckLatency 8.8.8.8:443,8.8.8.8:80 | Export-CSV -LiteralPath $csvFile -NoTypeInformation
Output with header
