Use the following procedures to build a simple runbook in System Center 2012 - Orchestrator by using branching logic.

For additional help, please refer to the on-line documentation for System Center 2012 - Orchestrator.

In the following exercise, you use a Monitor File activity and define the parameters that cause the runbook to start.

The activities that you select to perform actions in the runbook are the Copy File, Read Line, Append Line, and Delete File activities. The activities are configured to manipulate the data and achieve the results you want.

The purpose of this exercise is to detect when a specific type of file is added to a specified folder, copy that file to another folder, read the contents of the file, append a line from the copied file to another file, and then delete the original file. The activity that you select to invoke the runbook determines when the runbook runs.

To create a runbook

  1. Go to Start -> All Programs -> Microsoft System Center 2012 -> Orchestrator-> Runbook Designer.

  2. In the left hand Connections pane, right-click the Runbooks node, point to New, and then click Folder.

    A new folder appears and the folder name is highlighted for editing.

  3. Type New Runbook in the input box and press Enter.

  4. Right-click the New Runbook folder, select New, and then select Runbook.

  5. Beneath the Runbook Designer toolbar, right-click the New Runbook tab, and then click Rename.

    Click the Yes button in the Confirm Check out dialog box.

  6. Type Append and Copy Workflow in the input box and press Enter.

You have defined a new runbook and are ready to begin adding and configuring activities.

To add and configure a Monitor File activity

  1. In the Activity pane, with the newly created Append and Copy Workflow runbook open, expand the File Management category.

  2. Click and drag the Monitor File icon to the Runbook Designer.

  3. Double-click the Monitor File activity to edit the properties.

  4. Go to the In folder box, type C:\Drop.

  5. Click the Add button at the bottom.

  6. From the Filter Settings dialog box, click the Name menu and select File Name.

  7. Click the Relation menu, and set the relation to Matches Pattern.

  8. In the Value box, type *.txt.

  9. Click OK.

  10. Click the Triggers tab.

  11. In Trigger if one of the files was, check the Created box, and then click Finish.

The Monitor File activity is created and configured to watch for any new text files that are created in the C:\Drop folder.

To add branching logic to the runbook

  1. In the Activity pane, expand the File Management category.

  2. Click and drag the Copy File activity to the Runbook Designer.

  3. Expand the Text File Management category.

  4. Click and drag the Read Line activity to the Runbook Designer.

  5. Create a link between the Monitor File activity and the Copy File activity by clicking and dragging the right arrow of the Monitor File activity to the Copy File activity.

  6. Create a link between the Monitor File activity and the Read Line activity by clicking and dragging the right arrow of the Monitor File activity to the Read Line activity.

By adding both the Read Line activity and the Copy File activity, you have created a branch. These activities use the same set of data and run in parallel.

To configure a Copy File activity

  1. In the Append and Copy Workflow runbook right-click the Copy File activity, and then from the menu select Properties.

  2. On the Details tab, right-click the File box, click Subscribe, and then click Published Data to open the Published Data dialog box.

    The defaulted Activity listed at the top of the Published Data dialog box is Monitor File.

  3. From the Name column, select Name and path of the file, and then click OK.

  4. In the destination Folder box, type C:\Copy.

  5. Click Finish.

The Copy File activity is now configured to copy files from the target folder to the destination folder.

To configure a Read Line activity

  1. In the Append and Copy Workflow runbook, right-click the Read Line activity, and then from the menu select Properties.

  2. On the Details tab, right-click the File box, click Subscribe, and then click Published Data to open the Published Data dialog box.

    The defaulted Activity listed at the top of the Published Data dialog box is Monitor File.

  3. From the Name column, select Name and path of the file, and then click OK.

  4. In the destination Folder box, type C:\Copy.

  5. In the File encoding box, type auto.

  6. In the Line numbers box, type 1-END, and then click OK.Click Finish.

The Read Line activity is now configured.

To add an Append Line activity

  1. In the Activity pane, expand the Text File Management category.

  2. Click and drag the Append Line activity to the Runbook Designer to the right of the Read Line activity.

  3. Create a link between the Read Line activity and the Append Line activity by clicking and dragging the right arrow of the Read Line activity to the Append Line activity.

The Append Line activity is now added to the runbook.

To configure an Append Line activity

  1. In the Append and Copy Workflow runbook, right-click the Append Line activity, and then from the menu select Properties.

  2. On the Details tab, go to the File box and enter C:\Masterlog.txt.

  3. In the File encoding box, enter auto.

  4. Right-click the Text box, click Subscribe, and then click Published Data to open the Published Data dialog box.

    The defaulted Activity listed at the top of the Published Data dialog box is Read Line.

  5. From the Name column, select Line text, and then click OK.

  6. Click Finish.

The Append File activity is now configured to append files to the Masterlog.txt file.

To synchronize branches of a runbook

  1. In the Activity pane, expand the Runbook Control category.

  2. Click and drag the Junction icon to the Runbook Designer.

  3. Create a link between the Append Line activity and the Junction activity by clicking and dragging the right arrow of the Append Line activity to the Junction activity.

  4. Create a link between the Copy File activity and the Junction activity by clicking and dragging the right arrow of the Copy File activity to the Junction activity.

  5. Right-click the Junction activity, then from the menu select Properties.

  6. Next to the Return data from box, click the ellipses button (…), and from the Select an Activity dialog box, select Copy File.

  7. Click OK.

  8. Click Finish.

The Junction activity is configured, and the branches of the runbook are now synchronized.

To add and configure a Delete File activity

  1. In the Activity pane, expand the File Management category.

  2. Click and drag the Delete File icon to the Runbook Designer.

  3. Create a link between the Junction activity and the Delete File activity by clicking and dragging the right arrow of the Junction activity to the Delete File activity.

  4. Right-click the Delete File activity, and then from the menu select Properties.

  5. Right-click the Path box, click Subscribe, and then click Published Data to open the Published Data dialog box.

    From the Activity menu at the top of the Published Data dialog box, select Copy File.

  6. From the Name column, select Name and path of the destination file, and then click OK.

  7. Click Finish.

The Append and Copy Workflow runbook is now completed. To learn how to test this Append and Copy Workflow runbook, see How to Test a Runbook.