locked
Endless ping RRS feed

  • Question

  • Hi experts,

    Is there a way to make and endless ping in PowerShell like it was the "ping pcname -t" in batch scripts?

    Is there a switch which makes the similar thing than "-t" at the command ping?

    Currently I have only one idea:

    test-connection pcname -count 1000

    Where count has an extremely high value.

    Tuesday, June 21, 2011 3:56 PM

Answers

  • Hi Filippo,

    Just try use basic loop, like this:

    while($true){Test-Connection  <address> -Count 1}

    or

    while($true){Test-Connection  <address>  -Count 1; Start-Sleep -Seconds 1}

    • Marked as answer by Filippo Neri Wednesday, June 22, 2011 3:37 PM
    Wednesday, June 22, 2011 7:47 AM

All replies

  • why not using the ping command within powereshell?

    It works fine especially with the -t option.

     

    ping -t <ip-address>

     


    regards Thomas Paetzold visit my blog on: http://sus42.wordpress.com
    Tuesday, June 21, 2011 8:42 PM
  • Hi Filippo,

    Just try use basic loop, like this:

    while($true){Test-Connection  <address> -Count 1}

    or

    while($true){Test-Connection  <address>  -Count 1; Start-Sleep -Seconds 1}

    • Marked as answer by Filippo Neri Wednesday, June 22, 2011 3:37 PM
    Wednesday, June 22, 2011 7:47 AM
  • Hi MichalGajda,

    Thanks for your tip. It works well.

    How can I redirect the output to a file?

    I tried this, but it does not work :

    while($true) {Test-Connection  hs290lux1  -Count 1 | out-file d:\tmp\output.txt}

     

    Wednesday, June 22, 2011 3:40 PM
  • hmm...

    This should works, but remember if you send output to file you cant see it on secrean and if you dont want to rewrite file on each time use Append parametre.

    while($true) {Test-Connection  127.0.0.1  -Count 1 | out-file p:\output.txt -Append}

    Friday, June 24, 2011 5:27 PM
  • Hi MichalGajda,

    It works well but every line has its own header. Is it possible to eliminate this?
    Is it possible to log to the screen and to a log file at the same time?

    Monday, June 27, 2011 7:40 AM
  • $server | %{while($true){test-connection $_ -count 1} | tee -FilePath ping.txt

    tested and works.

    Monday, June 27, 2011 12:48 PM