Orchestrator 2022 passing parameters to runbook with API

Brad Davis 101 Reputation points
2022-09-28T12:16:15.073+00:00

Trying to call a runbook on Orchestrator 2022 with Powershell and pass parameters to runbook. I need to pass multiple parameters, but started with just one. It works fine when I remove the parameter from the runbook's Initialize Data and the Powershell API call, but as soon as I add it I get (400) Bad Request. Partial code below (removed some variable declarations for privacy):

$body = @{  
  
RunbookId = "0E3D0830-5BB6-4717-BB94-330E0338F153"  
  
Parameters = @{  
    "457F99B3-1267-4848-A91B-5F4B746BA1EA" = $Action  
    }  
  
CreatedBy = $null  
  
} | ConvertTo-Json  
  
Invoke-RestMethod -Uri ('{0}/api/Jobs' -f $OrchURI) -Body $body -Method Post -ContentType 'application/json' -UseDefaultCredentials  
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.
267 questions
Windows for business | Windows Server | User experience | PowerShell
{count} votes

1 answer

Sort by: Most helpful
  1. Fabien Gaille 5 Reputation points
    2023-03-07T12:16:12.21+00:00
    $body = @{
        RunbookId = $adminRoleRunbookId
       # RunbookId = $runbookId  
        RunbookServers = @($runbookServer)
        Parameters = @(
                    [pscustomobject]@{Name='Reason';Value='Some text'},
                    [pscustomobject]@{Name='User';Value='Some user'},
                    [pscustomobject]@{Name='Version';Value='Some version'}
                    )
        CreatedBy = $null 
    } | ConvertTo-Json 
    
    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.