Orchestrator 2022 passing parameters to runbook with API

Brad Davis 81 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.
214 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,358 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Fabien Gaille 0 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 
    
    0 comments No comments