Starting Runbook with PowerShell

To start an orchestrator runbook with PowerShell, Microsoft provide a reliable script in its MSDN web site.

https://msdn.microsoft.com/en-us/library/hh921685.aspx

 

But, as prerequisite, the script needs the GUIDs for runbook and runbook parameters. There are different ways to find these GUIDs. One of the easier is to use Excel, and more specifically the PowerPivot plugin. Thank you System Center Central for this tip, it works very well…

http://www.systemcentercentral.com/how-to-initiate-a-runbook-from-powershell-and-orchestrator-web-service-the-easy-way/

 

Here are the steps to retrieve data and start a runbook with PowerShell

  • Connecting Excel to the Orchestrator Web Service
  • Retrieving the GUID of the Runbook using PowerPivot
  • Retrieving the GUIDs of the Runbook Parameters using PowerPivot
  • Retrieving and updating the Sample Script provided by Microsoft
  • Running the Script

.

.

1. Find GUIDs of Runbook and parameters

Finding GUIDs for the Runbook and its parameters can be done easily using Excel and PowerPivot.

Power Pivot is an add-in allowing to perform data analysis in Excel.

This add-in is not enabled by default.

To enable PowerPivot:

  • Open Excel
  • Go to File > Options > Add-Ins
  • In the Manage box, click COM Add-ins > Go
  • Select “Microsoft Office PowerPivot”, click OKThe ribbon now has a Power Pivot tab.

PSStartRunbook01.

Now that PowerPivot is installed, it can be used to retrieve GUIDs of the Runbook and its parameters.

First, connect the Orchestrator Web Service with Excel:

  • Launch Excel using an account with access rights on the orchestrator server
  • Go to the PowerPivot tab
  • Click on the Manage button, to open the tool

PSStartRunbook02

.

PSStartRunbook03

Select the From Other Sources button to launch the Table Import Wizard

.

PSStartRunbook04

Select Other Feeds

Click Next

.

PSStartRunbook05

Type a friendly name for the connection

Type the Data Feed URL, generally like http://servername:81/Orchestrator2012/orchestrator.svc

Click Test Connection

.

PSStartRunbook06

If the test is successful, click OK, then Next

.

PSStartRunbook07

Select Runbooks

Select RunbookParameters

Click Finish

.

PSStartRunbook08

Tables are imported

Click Close

.

Runbook ID

Go to the Runbooks worksheet

PSStartRunbook09

.

On the Name column, filter on the runbook name and select it

PSStartRunbook10

.

Copy the Runbook ID (GUID)

PSStartRunbook11

.

.

Parameters ID

Go to the RunbookParameters worksheet

PSStartRunbook12

.

On the RunbookId column, filter on the runbook ID and select it

PSStartRunbook13

.

Copy the Runbook Parameters ID (GUID)

PSStartRunbook14

.

.

2. Create the PowerShell Script

Microsoft provides a sample PowerShell script for initiating runbooks from outside Orchestrator: http://msdn.microsoft.com/en-us/library/hh921685.aspx

Create a ps1 script using the following code:

.

Modify the value of the variable $rbid with the GUID of the Runbook without {}

.

Modify the value of the variable $rbParameters with the GUID of the Runbook Parameters without {}

Warning: The letters in the IDs of the runbook parameters must be in lowercase or Orchestrator web service returns a 500 error!

.

.

3. Run the Script

Run the script using an account with access rights to Orchestrator:

PSStartRunbook15