I was given this script by a vendor to run on some of my servers. I get some exceptions when I run it
Exception calling "Send" with "2" argument(s): "An exception occurred during a Ping request."
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : PingException
+ PSComputerName : localhost
Can someone tell me how to write the below with Test-Connection instead of System.Net.NetworkInformation.Ping. Here is the script
Function Test-Ping { $parallelCount = $args[0] #Thread Count $serverName =$args[1] $loop = $args[2] $wait = $args[3] $jobs = (1..$parallelCount) | % {start-job { $p = New-Object System.Net.NetworkInformation.Ping $serverName = $args[0] $wait = $args[2] (1..$args[1]) | % { $p.send($serverName, 10000); start-sleep -s $wait } } -ArgumentList $serverName,$loop,$wait} $jobs | wait-job $jobs | receive-job } Test-Ping 24 myservername 10 1