-Continuous switch with Test-Connection cmdlet - by Ravikanth.Chaganti

Status : 


Sign in
to vote
ID 676600 Comments
Status Active Workarounds
Type Suggestion Repros 0
Opened 6/23/2011 1:39:23 AM
Access Restriction Public


During my regular work, I keep using Ping -t a lot as Test-Connection has no -continuous parameter. This is essential for monitoring a system for continuous connection until it comes online or goes offline. With a -continuous switch, we can easily create an event based triggering mechanism. For example,

While (Test-Connection -cn Server01 -Continuous -Quiet) {
#may be sleep
#and here use New-Event to raise an event for the connection loss
#Do something with the event
And, this can be used in a background job to monitor systems async. 

We can create a proxy function today to do this. But, having the cmdlet implement this mechanism will be appropriate. There were also suggestions to use count parameter with a BIG number. But, count is count. It does not mean forever or until an event occurs.

So, I suggest that PowerShell vNext to include -Continuous parameter with Test-Connection cmdlet. When a user does not want to ping anymore, he/she will just press CTRL+C and break the session.
Sign in to post a comment.
Posted by Klaus Baldermann on 3/21/2016 at 2:32 AM
Admittedly, I did not try wether
    Test-Connection ... -Count ([Int32]::MaxValue)
really will go on for 68 years, but of course if Microsoft wants to show confidence in their systems, a -Continouous parameter would help that :-)
Posted by Ayan Mullick on 11/23/2014 at 10:15 AM
while($true){Test-connection abc}
Posted by Robert Heinig II on 8/14/2012 at 4:51 AM
I'd suggest supporting all or most options of ping.exe, especially -w, -4 and -6. -t is at least easy to approximate.