When using the Restart System activity in Orchestrator, the activity exits once the restart command has been sent to the remote system. When using this activity alone, there is no way to know if the system rebooted successfully. However, using a few other activities and some looping, you can make the runbook wait while the server is rebooting. In this example I made a runbook that I can pass a system name to, and have it return whether or not system successfully rebooted. I have provided the details on how to make this runbook below.
- Create a new runbook and open the Properties window.
- Navigate to the Returned Data tab and create a definition named “result”
- Initialize Data: Create a parameter named “Server”
- Restart System: Computer is set to the Server parameter from Initialize data. Set all other options to your preferences
- Get Computer/IP Status (renamed to Wait for Reboot): Computer is set to computer from Restart System
- Looping: Right click on Wait for Reboot and select Looping. Check Enable and set delay between attempts (in seconds). On the Exit tab you are first going to select Wait for Reboot returns warning or failed. This will cause this activity to continue to run as long as the runbook is able to ping the server, meaning it has not started to reboot yet. Once the server reboots, the activity will not be able to ping the system. This will return a failure, and in turn exit the loop. Also, you will want to create a fail safe exit condition incase the server does not reboot. Click Add to add an additional condition. Set this condition to Loop: Number of attempts from Wait for Reboot equal 300. This will make the activity exit if your system does not reboot in 5 minutes. Remember you have to select Show common Published Data to get the return information for the Loop.
- Success Link: In this case since the server being offline is the desired result, a failure is considered a success. Therefore you need to set the link between the Wait for Reboot and Wait for Post Boot to continue on warning or failed. Then on the exclude tab set the condition for Loop: Total duration from Wait for Reboot is greater than or equal to 300.
- Failure Link: If the server does not reboot in 300 seconds (5 minutes) then it will be considered a failure. For this, create a second link to the Return Failure activity and set it to include Loop: Total duration from Wait for Reboot is greater than or equal to 300
- Get Computer/IP Status (renamed to Wait for Post Boot): Computer is set to computer from Wait for Reboot
- Looping: Just like the Wait for Reboot activity, Looping will need to be enabled for the Wait for Post Boot activity. However, this time we will exit on success or a loop duration of 600 seconds (10 minutes). The logic behind this, is when the Wait for Reboot activity fails, the system has started to reboot and the runbook will continue to the Wait for Post Boot activity. Then, once the operating system starts back up again, Orchestrator will be able to ping the system and the Wait for Post Boot will be successful.
- Success Link: On the include tab you can leave the default Wait for Post Boot returns success. Then on the exclude tab set the condition for Loop: Total duration from Wait for Reboot is greater than or equal to 600.
- Failure Link: If the server does not come back online in 600 seconds (10 minutes) then it will be considered a failure. For this, create a second link to the Return Failure activity and set it to include Loop: Total duration from Wait for Reboot is greater than or equal to 600
- Return Data (renamed to Return Success): Set result to success
- Return Data (renamed to Return Failure): Set result to failure
And there you have it. You can now use the Invoke-Runbook activity for any other runbook where you need to reboot a system, and wait for it to come back online. Keep in mind when invoking this runbook you should check Wait for completion.