Let me first start by saying I've been using PowerShell for just over a month, so I'm a total n00b and this may be something simple.
What I need is a script that will reboot a list of servers in a text file, continuously ping them, and display a message to me as their status changes (Server is waiting for reboot, server is offline, server is online). I've been able to piece together stuff that will do it for a single server at a time (meaning it will do the process for the first server in the list, but won't start the second sever until server 1 is back online). I really need it to knows that server1 is still waiting to reboot so it moves on to server 2 and checks it...it knows that server 1 is offline but continues to cycle through the server list to check for status changes. As a server comes back online, it lets me know and then knows to not ping it from there on. I hope that makes sense.
Any help is greatly appreciate...I've been searching for a straightforward solution for a couple of weeks with no luck.
That's right. I found a GUI (PoshPAIG) that will let you reboot a list of servers and display as they go offline and back online. The tool is great, but what I'm trying to do is build a single script for me to use when I have to do weekend server maintenance. After everything comes back online I'll have it move on to checking services and prompting for any we want to restart and then it will collect system/application error/warning event logs from those servers. I've got the last parts done, i just need the ability to watch the servers drop and come back online. I was going to dig through the code for the gui, but it was a little overwhelming.
So what you want is a asynchronous function in order to ping multiple server concurrently.
A part of your answer is right here . This is a wonderful little piece of code by jrich which will let you run almost anything async.
Life is short, Enjoy it now. Cyreli
How was everything going on? Is there any update?
If there is anything that I can do for you please feel free let me know.
TechNet Community Support
I didn't get a chance to mess with it too much because a higher priority project came along, but when I did try it out it didn't seem to do what I was looking for it to do (not right "out of the box" at least). If I recall, it bounced a single server from the list and then waited to print anything to screen until the server came back up and it moved on to the next server. What I want (if possible) is for it to send a restart command to all server (about 20) on my list and then go through that list and let me know as each server drops and when it comes back up. Logically in my head I see it ping server 1 (see it's down, output that it's down, and move on), ping server 2 and do the same, same for server 3, etc. When it comes back around to server 1 and it's still down, it knows it already told me so it doesn't need to tell me again...just move on to server 2, then 3. When it comes back to server 1 and sees it's back up, it outputs that information, moves on to server 2, and takes server 1 out of the list so it knows not to alert me again. Maybe I'm expecting too much, but since I saw it perform like that in a GUI, I'm guessing there's a way.