Orchestrator is an awesome tool to automate and streamline processes, but as soon you would like to trigger some of those awesome runbooks you have created from outside orchestrator it can get a bit complicated.
In this post I will try to explain how to trigger Runbooks from powershell and how to find the IDâ€™s needed to pass parameters to the runbooks.
First, let us create a simple demo runbook
Configure the Initialize Data activity with 2 Parameters, Servername and IP Address
Then configure the send platform event activity to write the two parameters from Initialize data.
I have slightly modified the powershell script from http://msdn.microsoft.com/en-us/library/hh921685.aspx. I wanted the script to be a bit more versatile I therefore changed the way to run the script.
Run the the script like this:
.\StartRunbook.ps1 -server <WEBSERVICE SERVER GOES HERE> -RunbookID <RUNBOOKID GOES HERE> -Parameters ‘”<ACTIVITY ID GOES HERE>” = “<VALUE GOES HERE>”‘
.\StartRunbook.ps1 -server SCORCH01.DEMO.LOCAL -RunbookID 7701910d-73d2-42b4-8c13-295c3b4c726e -Parameters ‘”63cc5247-5332-4819-abb7-338deaf9dd2c” = “TESTVALUE”‘
Finding the IDs needed can be quite a hassle. Here are a few examples:
Finding the Runbook ID
From a VB script.
Change SQLServer and Database variable before running the script
NOTE: Script will return all Runbook IDs
Or simply open the SQL management tool and execute the following query against the database
SELECT UniqueID, Name FROM POLICIES where deleted =’0′ and Name = ‘Demo01’
Finding Parameter IDs
Locate the ID of the Runbook you want to use, open an internet browser and go to your Orchestrator web service address by typing something like this:
http://<SCORCH SERVER NAME>:81/Orchestrator2012/Orchestrator.svc/Runbooks(guid’<RUNBOOK ID>‘)/Parameters
This will bring up some xml similar to the following screenshot.
Locate the names of your parameters in the Initialize activity of the Runbook, then match them with the ID located in the <d:Id m:type=”Edm.Guid“></d:Id> section
You should now be able to trigger the runbook from the script by ruunning the following command:
.\StartRunbook.ps1 -server SCORCH01.DEMO.LOCAL -RunbookID EB9A4EEB-D5BD-4A6E-8125-B1FDDC7132E8 -Parameters ‘”9cfd8f22-2c2d-4eef-8861-ed855dd286ff” = “192.168.1.35”,”5ff1d8e1-d6a1-4433-a646-5cddd93a9452″ = “SERVER001″‘