Ping a server repeatdely every minute

I need a powershell script that will excute a ping command to a specific server with an adjustable time window . Like for example I may want to increase the window to ping every 1  minute or 5 minutes. The script will run froma task sequence using windows task manager .

It needs to be a powershell script so that I can have consistency if I need to do it on more servers . Please help
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Joe Winograd, Fellow&MVEDeveloperCommented:
Check out the PowerShell script at this EE thread:
Regards, Joe
Dr. KlahnPrincipal Software EngineerCommented:
If what you need is to determine whether the server is running properly with applications up and available as opposed to just the Windows TCP stack being alive, pinging is not the best way to go.  All applications on the system might be dead in the water but the network can still be running.  Joe can probably suggest a better way to determine if the server applications are running.
gd6627Author Commented:
Hello Joe how do i make this work Where do I define the server? and how can i run this from a task manger on windows server?
Joe Winograd, Fellow&MVEDeveloperCommented:
> Where do I define the server?

I don't know. I'm not a PowerShell expert. I pointed you to that thread because it has a lot of what you're looking for (I was just helping on the timeout-in-millseconds issue there). I see that you already posted a question there asking how to specify the server. I would post there again asking the folks on that thread to please take a look at this one, and post the URL for this one over there. That way, you won't "hijack" that thread, but the experts participating there will know of this thread and, hopefully, jump in here.

> how can i run this from a task manger on windows server?

You mean Task Scheduler, not Task Manager...and definitely not "manger". :)  To learn the basics of running a task with Task Scheduler, read my EE article:
How to use the Windows Task Scheduler - An Introduction

There may be some nuances for a PowerShell script (again, I'm not an expert in PS), but these recent EE threads should help you with that:

Regards, Joe

Update: Although I'm not a PS expert, I did some investigation and can now answer your question of "Where do I define the server?" The answer is in Shaun Vermaak's post at the other thread I mentioned above — so a big thanks to Shaun for that! As Shaun's code shows there, the server address is a parameter to the PingComp function and you specify it next to PingComp on the command line, as you would with other parameters for other functions. For example, to specify the server as, the PS command looks like this:


Likewise, to specify the server as, the PS command looks like this:


Here is actual PS output showing that those commands work, as well as an intentional error ( to show what happens in that case:

pingcomp with server specified
Regards, Joe

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Joe Winograd, Fellow&MVEDeveloperCommented:
The original question is for a PowerShell script that pings a specific server with an adjustable time window. A follow-on question is how to specify the server. I selected two posts that answer those questions as the Accepted Solution and an Assisted Solution, and gave them the lion's share of the points. But another post presented an interesting caveat about such an approach and is worthy of some points as an Assisted Solution.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.