tommym121
asked on
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"
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Where do I define the server ?
PingComp is a function. Run the script then you will have PingComp loaded
After that run
After that run
PingComp SomeServer
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.Response Time) 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.Response Time) m ...
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (LogMessage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundExceptions 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.Response
} 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.Response
+ ~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (LogMessage:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundExceptions is what I get ?
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.
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.