• Status: Solved
  • Priority: Medium
  • Security: Private
  • Views: 59
  • Last Modified:

Change the time out for the Ping

I am using the powershell  to perform ping test.  Below is the script. I want to increase the timeout to 10 seconds from 3 seconds.  Is it that I need to change the 'timeout=3000' to 'timeout=10000'?
Function PingComp([string]$sComp) {
  $vRet = Get-WmiObject -Query "Select * From Win32_PingStatus Where Address = '$sComp' and timeout=3000"

  if ($vRet) {
    if ($vRet.StatusCode -eq 0) {
      LogMessage "${sComp}|Computer responded|$($vRet.ResponseTime) ms"
    } else {
      LogMessage "${sComp}|Computer did not respond"
    }
  } else{
    LogMessage "${sComp}|ERROR|Null value returned"
  }
}

Open in new window

0
tommym121
Asked:
tommym121
  • 2
  • 2
  • 2
2 Solutions
 
Joe Winograd, Fellow&MVEDeveloperCommented:
I don't know if the script actually works, but I can tell you that the timeout param is in milliseconds:

1000 milliseconds = 1 second
3000 milliseconds = 3 seconds
10000 milliseconds = 10 seconds
etc.

So, you are correct! Regards, Joe
0
 
Shaun VermaakTechnical Specialist/DeveloperCommented:
Yes
PingComp.png
1
 
gd6627Commented:
Where do I define the server ?
0
Simplify Active Directory Administration

Administration of Active Directory does not have to be hard.  Too often what should be a simple task is made more difficult than it needs to be.The solution?  Hyena from SystemTools Software.  With ease-of-use as well as powerful importing and bulk updating capabilities.

 
Shaun VermaakTechnical Specialist/DeveloperCommented:
PingComp is a function. Run the script then you will have PingComp loaded

After that run
PingComp SomeServer

Open in new window

0
 
gd6627Commented:
This is what I get?

Function PingComp([string]$sComp) {
  $vRet = Get-WmiObject -Query "Select * From Win32_PingStatus Where Address = '$sComp' and timeout=3000"

  if ($vRet) {
    if ($vRet.StatusCode -eq 0) {
      LogMessage "${sComp}|Computer responded|$($vRet.ResponseTime) ms"
    } else {
      LogMessage "${sComp}|Computer did not respond"
    }
  } else{
    LogMessage "${sComp}|ERROR|Null value returned"
  }
}
pingComp OAk-dc-v01
LogMessage : The term 'LogMessage' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At line:6 char:7
+       LogMessage "${sComp}|Computer responded|$($vRet.ResponseTime) m ...
+       ~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (LogMessage:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundExceptions is what I get ?
0
 
Joe Winograd, Fellow&MVEDeveloperCommented:
The original question is: "I want to increase the timeout to 10 seconds from 3 seconds. Is it that I need to change the 'timeout=3000' to 'timeout=10000'?"

The answer to that is yes, since the timeout parameter is in milliseconds, and the first post answers it, worthy as the Accepted Solution. The second post shows a test run of the script and is very helpful, worthy as an Assisted Solution. Splitting the points evenly between those two experts. Follow-on questions are not by the OP, so not including comments about them as solutions.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now