[Net.NetworkInformation.Ping]::New().SendPingAsync() - too fast?

Ask your PowerShell-related questions, including questions on cmdlet development!
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

[Net.NetworkInformation.Ping]::New().SendPingAsync() - too fast?

Post by localpct »

So I was doing some testing on how to get the fastest, ping return on machines
as we know, test-connection has a three second delay if the PC isn't found

So in comes [Net.NetworkInformation.Ping]::New().SendPingAsync()

I have found it likes to give me false statements, such as, a PC in California, will ping fine, then the next time it doesn't. It will say it cannot find it. Run it again, finds it. I thought it was because I was on VPN this weekend, but now I'm wired still having the same issues.

This is my script, super easy
  1. foreach ($D in $DNS)
  2. {
  3.     $ping = [Net.NetworkInformation.Ping]::New().SendPingAsync("$server.$D",250) | Where-Object {$_.Result.Status -eq 'Success'}
  4.     if($ping){
  5.     "$server.$suffix".toupper();
  6.   break
  7. }
  8. else{
  9. }
  10. }
jvierra
Posts: 15439
Last visit: Tue Nov 21, 2023 6:37 pm
Answers: 30
Has voted: 4 times
Been upvoted: 33 times

Re: [Net.NetworkInformation.Ping]::New().SendPingAsync() - too fast?

Post by jvierra »

This is not a scripting issue. It sounds like your DNS servers have issues.
User avatar
localpct
Posts: 397
Last visit: Thu Oct 27, 2022 5:57 am

Re: [Net.NetworkInformation.Ping]::New().SendPingAsync() - too fast?

Post by localpct »

that is an answer I can live with. I also had this issue with Asynchronous Network Ping
https://gallery.technet.microsoft.com/s ... g-abdf01aa
This topic is 4 years and 5 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked