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
gd6627Asked:
Who is Participating?
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:
https://www.experts-exchange.com/questions/29080171/Change-the-time-out-for-the-Ping.html
Regards, Joe
0
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.
0
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?
0
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:

https://www.experts-exchange.com/questions/29070937/How-do-I-run-a-powershell-script-as-a-task-in-task-scheduler.html
https://www.experts-exchange.com/questions/29079288/Automate-Powershell-command-with-task-scheduler.html
https://www.experts-exchange.com/questions/29079642/Task-Scheduler-Powershell-bat-file.html

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 192.168.0.1, the PS command looks like this:

pingcomp 192.168.0.1

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

pingcomp google.com

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

pingcomp with server specified
Regards, Joe
0

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.
0
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
Powershell

From novice to tech pro — start learning today.

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.