Archive for the ‘Start Runbook’ Tag

High Availability for Runbook Servers on Invoking Runbooks   Leave a comment

I’ve moved everything from this blog over to jmattivi.blogspot.com and updated all of the scripts to have straight quotes.  If any don’t work as posted, please let me know!

For further posts please see jmattivi.blogspot.com.

Thanks!

 

Here’s just a quick tidbit for specifying runbook servers used in the Invoke Runbook standard activity.  It’s beneficial to keep the runbook server names stored in Global Variables.  This way you can insert the variable in the Invoke Runbook activity instead of hardcoding the server name.

In case a runbook server has issues and is powered down or unavailable, the invoke runbook activity will automatically start the invoked runbook on the next runbook server in line.  Another benefit is the ability to add/remove runbook servers and just update a variable than trying to find/replace every invoke runbook activity w/ the new server name.

You can also use the variables to group runbook servers based on their role in the environment.  So to load balance runbooks, depending on how many runbook servers you have (for this example we’ll say three internal).  You could specify three variables which have the following values.

Primary:  myrunbookserver1;myrunbookserver2;myrunbookserver3

Secondary:  myrunbookserver2;myrunbookserver3;myrunbookserver1

Tertiary:  myrunbookserver3;myrunbookserver1;myrunbookserver2

So for runbook servers interacting w/ servers on an internal domain you could use:

So for runbook servers interacting w/ servers on a dmz domain you could use:

Finally, subscribe to the variable in the Invoke Runbook activity.

Start Runbooks from SharePoint List   Leave a comment

I’ve moved everything from this blog over to jmattivi.blogspot.com and updated all of the scripts to have straight quotes.  If any don’t work as posted, please let me know!

For further posts please see jmattivi.blogspot.com.

Thanks!

 

After stopping all running/pending runbooks to perform maintenance on the SCOrch environment, it becomes cumbersome to start all runbooks that begin with a monitor date/time activity (especially when the number of runbooks to start climbs above 100….).

You can create a SharePoint list (Figure A) of runbooks that need to be started after maintenance (good to document nonetheless) that Orchestrator can reference to start all of them automatically!

The main field that we need to use is the RunbookID in the SP list.  I also use a field called “Active” in the list to exclude workflows that may not need started in case there is any reason that they shouldn’t be started for the time being.

Figure A

The workflow is made up of three runbooks.  A main which queries the SP list for the active runbook ids to start, the execute which starts the targeted runbook, and a seperate runbook to keep track of processed runbooks to later check for any errors.

Main (Figure B)

Figure B

The main starts by resetting a counter to cleanup from previous runs.  Then it uses the Microsoft SharePoint IP by Jeff Fanjoy (more info here http://orchestrator.codeplex.com/releases/view/75877) to query the list identified in the SP IP configuration in options.  Within the properties of the Get Active Runbooks activity, the filter is modified to choose the “Active” field set on the list object (Figure C).

Figure C

From the runbooks found in the list query, it will invoke the execute runbook with the runbook id and runbook name.  It also invokes the counter modification runbook with a parameter – increment (note this invoke must set the property to wait for completion – See Figure E).

Exploring the execute runbook that’s invoked in Figure D….it uses the Standard Logging IP (more info here http://orchestrator.codeplex.com/releases/view/76097).  It starts the targeted runbook (you can reference this from my previous post – https://jmattivi.wordpress.com/2012/01/08/scorch-powershell-startrunbook_part1/).  Upon success or failure to start the runbook, it invokes the counter modification runbook with a parameter – decrement (note this invoke must set the property to wait for completion – See Figure E).

Figure D

Figure E

Moving back to the Main runbook (Figure B), it waits for the counter value to be 0 – indicating processing has completed.  If not it hits a timeout after 15 minutes and sends an error email for investigation.  It then queries the Standard Logging table in the database for any failures to start runbooks from the execute runbook.  If errors are found, it uses a Powershell script to parse the flattened data back into multi-valued data and send that information in an email.  If no failures are found, it sends a success email that all targeted scheduled runbooks have been started successfully.

SCOrch – Powershell to start Runbook – Part 2   8 comments

I’ve moved everything from this blog over to jmattivi.blogspot.com and updated all of the scripts to have straight quotes.  If any don’t work as posted, please let me know!

For further posts please see jmattivi.blogspot.com.

Thanks!

 

Here is an example to start a Runbook w/ parameters from Powershell.  It’s pretty much the same exact as a standard POST to start a Runbook, but also includes the parameters in the properties struct.

I’ve found that the free program Fiddler helps to find the guids and struct needed to build the POST.  You can also use the Orchestration Console to drill down through to the Instance Summary and Activity Details to find the guids for each parameter.

This is the parameters struct that is added to the regular POST.

Parameter1/Parameter2 are the names that you give the parameter.

You need to specify the guid for each parameter.

Value1/Value2 are the input values you’d like to specify for the Initialize Data activity.

<d:Parameters>&lt;Data&gt;&lt;Parameter&gt;&lt;Name&gt;Parameter1&lt;/Name&gt;&lt;ID&gt;{10000000-0000-0000-0000-000000000000}&lt;/ID&gt;&lt;Value&gt;Value1&lt;/Value&gt;&lt;/Parameter&gt;&lt;Parameter&gt;&lt;Name&gt;Parameter2&lt;/Name&gt;&lt;ID&gt;{20000000-0000-0000-0000-000000000000}&lt;/ID&gt;&lt;Value&gt;Value2&lt;/Value&gt;&lt;/Parameter&gt;&lt;/Data&gt;</d:Parameters>

Here is the complete script to include the parameters in the POST to start the Runbook.  The fields in red would need updated to your environment.

##############################################################################

$creds = Get-Credential(“domain\username”)

$url = “http://scorch.domain:81/Orchestrator2012/Orchestrator.svc/Jobs/

$request = [System.Net.HttpWebRequest]::Create($url)

$request.Credentials = $creds

$request.Timeout = 60000

$request.Accept = “application/atom+xml,application/xml”

$request.Headers.Add(“Accept-Charset”, “UTF-8″)

$request.ContentType = “application/atom+xml”

$request.Method = “POST”

$requestBody = ‘<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>

<entry xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom“>

<content type=”application/xml”>

<m:properties>

<d:Parameters>&lt;Data&gt;&lt;Parameter&gt;&lt;Name&gt;Parameter1&lt;/Name&gt;&lt;ID&gt;{10000000-0000-0000-0000-000000000000}&lt;/ID&gt;&lt;Value&gt;Value1&lt;/Value&gt;&lt;/Parameter&gt;&lt;Parameter&gt;&lt;Name&gt;Parameter2&lt;/Name&gt;&lt;ID&gt;{20000000-0000-0000-0000-000000000000}&lt;/ID&gt;&lt;Value&gt;Value2&lt;/Value&gt;&lt;/Parameter&gt;&lt;/Data&gt;</d:Parameters>

<d:RunbookId type=”Edm.Guid”>00000000-0000-0000-0000-000000000000</d:RunbookId>

</m:properties>

</content>

</entry>

$requeststream=new-object System.IO.StreamWriter $request.GetRequestStream()

$requeststream.Write($requestBody)

$requeststream.Flush()

$requeststream.Close()

$response=$request.GetResponse()

$requestStream=$response.GetResponseStream()

$readStream=new-object System.IO.StreamReader $requestStream

$Output=$readStream.ReadToEnd()

$readStream.Close()

$response.Close()

##############################################################################

SCOrch – Powershell to start Runbook – Part 1   Leave a comment

I’ve moved everything from this blog over to jmattivi.blogspot.com and updated all of the scripts to have straight quotes.  If any don’t work as posted, please let me know!

For further posts please see jmattivi.blogspot.com.

Thanks!

 

I have seen a few examples of ways to start a runbook with C and VB.  However, I haven’t come across any ways of using Powershell to start a runbook successfully.

This will be the first post of a series of different ways to interact w/ the web service through Powershell.  I’ll also post how to start w/ parameters, stop a runbook, get all running/pending runbooks, etc….

Here’s the short of it.  I Haven’t built any logic, parameters, or error handling into it yet….just wanted to get the POST to work with Orchestrator’s web service.

You would need to update the credentials, url for the web service pointed to the Jobs collection, and the RunbookID in the request body.

##############################################################################

$creds = Get-Credential(“domain\username”)

$Output = $null

$Success = $null

$url = “http://scorch.domain:81/Orchestrator2012/Orchestrator.svc/Jobs/

$request = [System.Net.HttpWebRequest]::Create($url)

$request.Credentials = $creds

$request.Timeout = 36000

$request.Accept = “application/atom+xml,application/xml”

$request.Headers.Add(“Accept-Charset”, “UTF-8”)

$request.ContentType = “application/atom+xml”

$request.Method = “POST”

#Request w/o Parameters

$requestBody = ‘<?xml version=”1.0″ encoding=”utf-8″ standalone=”yes”?>

<entry xmlns:d=”http://schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=”http://schemas.microsoft.com/ado/2007/08/dataservices/metadata” xmlns=”http://www.w3.org/2005/Atom“>

<content type=”application/xml”>

<m:properties>

<d:RunbookId type=”Edm.Guid”>RunbookGUID</d:RunbookId>

</m:properties>

</content>

</entry>

$requeststream=new-object System.IO.StreamWriter $request.GetRequestStream()

$requeststream.Write($requestBody)

$requeststream.Flush()

$requeststream.Close()

$response=$request.GetResponse()

$requestStream=$response.GetResponseStream()

$readStream=new-object System.IO.StreamReader $requestStream

$Output=$readStream.ReadToEnd()

$readStream.Close()

$response.Close()

$Output

##############################################################################