Runbook Parameter
Applies To: System Center 2012 - Orchestrator, System Center 2012 R2 Orchestrator, System Center 2012 SP1 - Orchestrator
The Runbook Parameter entity represents the parameters of Orchestrator runbooks. The Runbook Parameters collection includes all of the parameters from all runbooks installed on the local Orchestrator environment. You can use a query to filter the parameters for a single runbook.
A runbook can have input parameters that are defined in an Initialize Data activity. These are values that the runbook requires to run properly. It can also have output parameters that are defined on the Returned Data tab of the runbook’s properties. These values can be set with a Return Data activity. The type of parameter is specified with the Direction property.
Properties
The following table lists the properties of the Runbook Parameter entity.
Name |
Type |
Key |
Description |
Description |
String |
No |
Description of the runbook parameter |
Direction |
String |
No |
The direction of the parameter. A value of In specifies an input parameter for the runbook. A value of out |
Id |
GUID |
Yes |
GUID of the runbook parameter |
Name |
String |
No |
Name of the runbook parameter |
RunbookId |
GUID |
No |
GUID of the parameter’s runbook |
Relationships
The following table lists the entities that share a relationship with the Runbook Parameter entity and the key property in each entity used to define the relationship.
Entity |
Relationship |
Related Entity Property |
Runbook Parameter Entity Property |
Runbook |
Parent |
Id |
RunbookId |
Instance |
Child |
RunbookParameterId |
Id |
Code Samples
Getting a Runbook with its Parameters Using C#
The following code retrieves the parameters for a runbook that has a particular GUID using C#. It outputs to the console properties from the runbook and the direction and name of each parameter. You can uncomment the line that specifies alternate credentials if the current user does not have appropriate permissions to the runbook being started. For more information see Programming in Visual Studio With the Orchestrator Web Service and Authentication and Authorization.
namespace CodeSample.Microsoft.SystemCenter.Orchestration.WebService
{
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.IO;
using System.Data.Services.Client;
using SCO.SCOService;
public class SingleRunbook
{
public static void Main()
{
Guid runbookId = new Guid("00000000-0000-0000-0000-000000000000");
// Path to Orchestrator web service
string serviceRoot = "http://server01.contoso.com:81/Orchestrator2012/Orchestrator.svc";
// Create Orchestrator context
SCOService.OrchestratorContext context = new SCOData.OrchestratorContext(new Uri(serviceRoot));
// Set credentials to default or to a specific user.
context.Credentials = System.Net.CredentialCache.DefaultCredentials;
//context.Credentials = new System.Net.NetworkCredential("user", "pwd", "domain");
// Retrieve the runbook
Runbook runbook = context.Runbooks.Where(rbk => rbk.Id == runbookId).FirstOrDefault();
// Retrieve parameters
var runbookParams = context.RunbookParameters.Where(runbookParam => runbookParam.RunbookId == runbookId);
// Output runbook properties to console
Console.WriteLine("Id: {0}", runbook.Id);
Console.WriteLine("Name: {0}", runbook.Name);
Console.WriteLine("IsMonitor: {0}", runbook.IsMonitor);
Console.WriteLine("Parameters:");
// Output properties for each parameter to console
foreach (var param in runbookParams)
{
Console.WriteLine("\t{0} {1}", param.Direction, param.Name);
}
}
}
}
Getting Runbook Parameters Using Windows PowerShell
The following code retrieves the parameters for a runbook that has a particular GUID using Windows PowerShell. It outputs to the console the name and direction of each parameter. The example uses the credentials of the current user context. You can uncomment the line that specifies alternate credentials if the current user does not have appropriate permissions to the runbook being started. For more information see Authentication and Authorization.
# Details of the runbook we want to get
$runbookId = "00000000-0000-0000-0000-000000000000"
# Create the request object
$url = -join ("http://server01.contoso.com:81/Orchestrator2012/Orchestrator.svc/","Runbooks(guid'",$runbookId.ToString(),"')/Parameters")
$request = [System.Net.HttpWebRequest]::Create($url)
# Set the credentials to default or prompt for credentials
$request.UseDefaultCredentials = $true
# $request.Credentials = Get-Credential
# Build the request header
$request.Method = "GET"
$request.UserAgent = "Microsoft ADO.NET Data Services"
# Get the response from the request
[System.Net.HttpWebResponse] $response = [System.Net.HttpWebResponse] $Request.GetResponse()
# Write the HttpWebResponse to String
$reader = [IO.StreamReader] $response.GetResponseStream()
$output = $reader.ReadToEnd()
[xml]$output = $output
$reader.Close()
# Output properties of each parameters
foreach ($parameter in $output.feed.entry)
{
Write-Host "Name: " $parameter.content.properties.Name
Write-Host "Direction: " $parameter.content.properties.Direction
}
See Also
Concepts
Programming Using the Orchestrator Web Service
OData Queries Using the Orchestrator Web Service