I sometimes find it redundant looking up the runbook and parameter guids when creating a new powershell script to invoke a runbook from the web service. Here is a SQL query to look up the runbook by name and every parameter that you would need to use the web service to start the runbook.
Select lower(POLICIES.UniqueID) as RunbookID, lower(CUSTOM_START_PARAMETERS.UniqueID) as ParameterID, CUSTOM_START_PARAMETERS.value
From POLICIES
INNER JOIN OBJECTS on POLICIES.UniqueID = OBJECTS.ParentID
LEFT OUTER JOIN CUSTOM_START_PARAMETERS on OBJECTS.UniqueID = CUSTOM_START_PARAMETERS.ParentID
Where POLICIES.Name = 'My Runbook Name' and policies.deleted = 0
Note that the query uses the lower() function to force the guids to lowercase. This is required for the parameters when invoking a runbook or you will receive a 500 Internal Server Error. The runbook guid doesn't seem to matter if it's upper or lower case, but the parameters NEED to be in lowercase (bug??/feature??).
This will return the PolicyID (RunbookID), Parameter guid, and the name required to start the runbook from the web service.
Can I not simply do a HTTP POST to the webservice to start a runbook?? ie;
ReplyDeletehttp://orchestrator:81/Orchestrator2012/Orchestrator.svc/Runbooks(guid'037dbb9a-0f7d-4286-8485-b83ecd811e76')/ComputerName=test
For this example my only parameter is called "ComputerName".
If so, how do i do that exactly?
You absolutely can. However, to start or stop(cancel) a runbook you have to POST to the Jobs collection (not the Runbooks collection in your example).
DeleteSee one of my previous posts below to start runbooks through the web service w/ parameters. To do this though, you'll need the parameter guid which the SQL query in this post gives you.
http://jmattivi.blogspot.com/2012/06/scorch-powershell-to-start-runbook-part_02.html
Let me know if you have any other questions or issues.
Thanks!
Sorry, I meant to say HTTP GET. We have a PERL program that we want to simply add a web service call to orchestrator using HTTP GET. Assuming this is my RUNBOOK ID in the example how would I do that. I'm looking at your previous post and you're using HTTP POST. I dont' want to have to leverage any other scripting language or program...just want to hit the URL with the parameter set and initiate the runbook. I hope I'm clear with this, and I truly appreciate your help,thanks;
Deletehttp://orchestrator:81/Orchestrator2012/Orchestrator.svc/Runbooks(guid'037dbb9a-0f7d-4286-8485-b83ecd811e76')/ComputerName=test
After I replied, I read your comment again and thought that's what you meant :)
ReplyDeleteUnfortunately, the answer is no....you cannot just do a GET request to start a runbook.
I don't have much (or any) knowledge about orchestrator, however, I thought I'd mention that any state changing actions are almost always performed with a PUT or a POST. GET is all about viewing data. These conventions are in place for many reasons, perhaps the most important being security.
ReplyDeleteFor the SQL query, I suggest adding to the WHERE clause:
ReplyDeleteAND OBJECTS.Deleted != 1
Without this, the query returns objects that have been removed from the runbook, which probably won't be useful.