System Center Orchestrator 2012 : PingList RunBook

Hi community members,

Today, I will show how to create a simple Ping List Runbook with System Center Orchestrator 2012.

The main idea is to have a text file as input, this text file contains just a list of computers that we want to ping. As output, we want to have the computer name and next to it, a False or True value depending of the ping command succeeded or not.

So Let’s playing with System Center Orchestrator 2012 Smile

1. Open the System Center Orchestrator Runbook Designer.
image

2. Create a new folder and in it, create a new Runbook.
image

3. We will use the following activities :
image

4. Link each activity with the one on the right, and we will rename the activities for having a clear view of what our Runbook will do.
 image

5. We will now create the variables that we will use in our Runbook. Go to Global Settings > Variables and create a new folder.
image

6. Create 3 new variables :

  • Filepath : Path to the text file that contains the computer names that we want to ping.
  • OutputFolder : Folder that will contain the result file of this PingList runbook.
  • TimeOut : Value that we want to use with the ping command.

image

7. Go back to the PingList Runbook and open the Initialize Data activity. As in this Runbook, we will directly use variables, we don’t have to add anything here. So leave it blank as default. image
I supposed that you notice that this Initialize Data activity correspond to the Custom Start activity available in Opalis, Microsoft just renamed it.

8. We use the Format Date/Time activity to add the Date and Time in the name of the output file. In the Input part, Date/Time field, do a right click and select Subscribe > Returned Data.
image

9. Check the box Show common Returned Data, and select the Activity start time variable.
image

10. In the Output part, we format the date in that way : M-d-yyyy_h-m-s. Of course, you could chose your own date/time format, just don’t forget that file name has some character restrictions.
image

11. The Format Date/Time activity must be similar to that:
image

12. In the Read Line activity, we have to specify the file in which we will read the computer names. In the File field, do a right click > Subscribe > Variable and select the FilePath variable that we defined earlier. As we want to read the input file until the end, we have to add the 1-END in the line numbers field.
image

13. The Ping activity is in fact a PowerShell function that I wrote some years ago. This function simply takes the computer name and a timeout value as input and return TRUE if the computer answered to ping and FALSE if not.

Here the PowerShell function :
function Ping (  [string]$strComputer,[int]$timeout=500)
{
trap { continue; }
$ping = new-object System.Net.NetworkInformation.Ping
$reply = new-object System.Net.NetworkInformation.PingReply

$reply = $ping.Send($strComputer, $timeout);
if( $reply.Status -eq “Success”  )
  {
  return $true;
  }
  return $false;
}

EDIT :
TrondHindenes, one
of our user group member noticed that indeed of the PowerShell function that I
propose, we could simply use the following PowerShell command : test-connection –quiet Which return directly
True or False. Thanks to him !

Just below this PowerShell function in the Run .Net activity, we have to call the function and specify the inputs like below :
image

14. Still in the Run .Net activity don’t forget to publish the output :
image

15. In the Output activity, we will specify the name of the output file like below:{OutputFolder}PingResult-{format Result from “Format Date/Time”}.txt

Each line will have the following format:
{Line text from “Read Line”},{PingStatus from “Ping”}

image

16. “Et voilà”, now we just have to test our new PingList Runbook. Go to your input file and specify some computer names.
image

17. Start the PIngList Runbook :
image

18. Confirm that the Runbook ran successfully:
image

19. Go to the output folder, we have now a new file with the results of our Ping. 
image

20. Finally, enjoy the result Smile 
image

You could download this complete PingList Runbook at the following address : DOWNLOAD

Cheers
Christopher KEYAERT

Tweet about this on TwitterShare on FacebookShare on LinkedInShare on Google+Email this to someoneShare on TumblrPin on PinterestDigg thisShare on RedditFlattr the authorBuffer this pageShare on StumbleUpon

About Christopher Keyaert

Christopher Keyaert is a Consultant, focused on helping partners to leverage the System Center and Microsoft Azure cloud platform. He is also a Microsoft Most Valuable Professional (MVP) for Cloud and Data Center Management and a Microsoft Certified Trainer (MCT).
This entry was posted in Uncategorized. Bookmark the permalink.

0 Responses to System Center Orchestrator 2012 : PingList RunBook

  1. TrondHindenes says:

    Instead of you custom powershell command you could simply use “test-connection -quiet” which returns true/false.

  2. christopher@vnext.be says:

    Oh really great command. I didn’t know this command. I will edit my post.

Leave a Reply

Your email address will not be published. Required fields are marked *