Incrementing Lines in Orchestrator Runbooks

First of all, I love Orchestrator. Like…seriously. If it was able to walk upright and wasn’t so obnoxious at dinners, I may leave my wife for it…however, our relationship will probably go no further than me using it when I need to make my life simpler.

One of these scenarios just came up, as a matter of fact. As you may/may not know from previous posts, I had to migrate data from one SCSM environment to another. Rather than do this manually, I created an ENORMOUS runbook that handled the transfer of all open incidents. That, my friends, is to come in future posts (yes, it must be spread across multiple). For this post, I just wanted to simply display a technique that I used to increment lines in the runbook as to cover an entire list of incidents.

To do this, I first created two text files. One text file contained a single line with then number “1” called Line.txt. The second text file, called Incident.txt, contained a list of IR numbers, one on each line.

Next, I used two Read Line activities from the Text File Management grouping. The first I titled “Increments” and the second “Read Line”.

For the Increments activity, I pointed to the file location, chose ASCII for the file encoding and entered “1” for the line numbers portion. For the Read Line activity, I did the same for the file location and encoding, but for the line numbers I subscribed to the line text published data from the Increments activity.

“This is all good, Jesse, but how does it know to go to the next line?” Please, please practice some patience. I’m getting there.

A couple actions down (it doesn’t matter exactly where, as long as it is after you utilize the data you gather), I created two more activities. The first is a Run .Net Script activity called “Increment Number” in which I ran a Powershell script to bump the number up one (the script is below this paragraph). IMPORTANT: do not forget to add to the Published Data tab (in this case, create a string that has the name NumberString and variable NumberString). 

_______________Increment Number_______________

$ID = {Line text from “Increments”}

$NextNumber = [int]$ID

$NextNumber = $NextNumber +1

$NumberString = $NextNumber.ToString()

__________________________________________________

The next was a Search and Replace Text activity from the Text File Management grouping, which took the line text from Increments and replaced it with the NumberString from the Increment Number script.

Now, with a monitor up front to kick the runbook off as needed, our runbook will successfully move to the next line containing a new IR. Now, back to sleep while this runs…

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s