Orchestrator management using SCORCH API

Unlock the full potential of IT automation and orchestration capabilities with Orchestrator Management solution powered by the System Center Orchestrator (SCORCH) API. Streamline and optimize complex business processes by seamlessly integrating SCORCH into an existing IT infrastructure.

Yoel Borovsky

1/13/20242 min read

Background: In the transition to the older Service API within System Center Orchestrator 2022, managing system processes has become notably simpler. This transition not only facilitates faster and more efficient process management but also enhances the end-user interface compatibility with Edge or Chrome browsers. The only absence in this version is the statistics featured in the old interface, which can now be obtained through the SquaredUp dashboard or Grafana (note that SquaredUp relies on SCOM).

Implementation: To harness these improvements, the Orchestrator Web API needs installation on the web server. Utilizing default settings, the Console operates on port 82, while the Web API functions on port 81. Post-installation, navigating to http://orch-01:81/$odata exposes all available functions. This post emphasizes exploring specific functions, detailing how to use them, and providing a practical demonstration of working with processes in real-time through the PowerShell Console using the Invoke-WebMethod command :

#Orchestrator Web API URL

$OrchURI = 'http://<Replace with your server name>:81'

#To list all Runbook Servers

$RunbookServers = @(Invoke-RestMethod -Uri ('{0}/api/RunbookServers' -f $OrchURI) - UseDefaultCredentials | Select -ExpandProperty value | Select -ExpandProperty Name)

#To list all available Runbooks

Invoke-RestMethod -uri ('{0}/api/Runbooks' -f $OrchURI) -UseDefaultCredentials | Select - ExpandProperty value

#To list all Jobs currently running

$CurrentJobs = Invoke-RestMethod -Uri ('{0}/api/Jobs?$filter=Status%20in%20(%27Running%27,%27Pending%27)&$expand=Runbook($se lect=Name),RunbookInstances' -f $OrchURI) -UseDefaultCredentials | Select -ExpandProperty value

#To start runbook, copy the Runbook server id (from web UI link, or from previous command " To list all Runbook Servers"

$JobIDRB = '<Runbook ID>'

# To Start a runbook

$body = @{ RunbookId = $JobIDRB RunbookServers = $RunbookServers Parameters = @() CreatedBy = $null } | ConvertTo-Json Invoke-RestMethod -Uri ('{0}/api/Jobs' -f $OrchURI) -Body $body -Method Post -ContentType 'application/json' -UseDefaultCredentials

#To stop job of specific runbook, get the Job Id or from portal UI or from the "To list all Jobs currently running" command

$JobID = "<Job_ID>"

Invoke-RestMethod -Uri ('{0}/api/jobs/{1}' -f $OrchURI,$JobID ) -UseDefaultCredentials -Method Patch

#To canceled jobs from specific runbook

[array]$AllJobs = $CurrentJobs | ?{$_.RunbookId -eq $JobIdRB}

$AllJobs | ForEach-Object{

$ID = $_.Id

Invoke-RestMethod -Uri ('{0}/api/jobs/{1}' -f $OrchURI,$ID) -UseDefaultCredentials -Method Patch -ErrorAction SilentlyContinue

}