Trigger SC Orchestrator 2022 Runbook via JSON based Web API

McDaniel, Dave 71 Reputation points
2022-08-19T22:14:49.063+00:00

I am attempting to trigger a runbook via the new SCO Web Api using Powershell invoke-Rest Method. I am able to successfully retrieve Runbooks, however I have not been able to successfully trigger a runbook yet. Any help is appreciated. Below is example of powershell i have been using.

$RunbookURL = 'http://<Orchestratorserver>:<port>/api/runbooks'

$RB_ID = "<Runbook ID>"

$JobUrl = 'http://<Orchestratorserver>:<port>/api/jobs'

$Runbooks = Invoke-RestMethod -Uri $RunbookURL -UseDefaultCredentials -Method Get

$Runbook = $Runbooks.value | where-object{$_.ID -eq "$RB_ID"}

$Body = '{

"RunbookId":  "$RB_ID",  
"Parameters: null,  
 

}'|ConvertTo-Json

$ExecuteRBresponse = Invoke-RestMethod -Uri $JobUrl -UseDefaultCredentials -Method Post -Body $Body -ContentType "application/json"

System Center Orchestrator
System Center Orchestrator
A family of System Center products that provide an automation platform for orchestrating and integrating both Microsoft and non-Microsoft IT tools.
214 questions
{count} votes

Accepted answer
  1. Brad Davis 81 Reputation points
    2022-09-28T14:13:29.653+00:00

    here is what have that works:

    # Details of the runbook we are going to run  
    $rbid = "0E3D0830-5BB6-4717-BB94-330E0338F153"    
      
    $OrchURI = 'http://<SERVERFQDN>:81' #Replace 81 by the WebService port  
      
    # To Start a job  
    $body = @{  
      
    RunbookId = $rbid  
      
    CreatedBy = $null  
      
    } | ConvertTo-Json  
      
    Invoke-RestMethod -Uri ('{0}/api/Jobs' -f $OrchURI) -Body $body -Method Post -ContentType 'application/json' -UseDefaultCredentials  
    

0 additional answers

Sort by: Most helpful