Runbook
Applies To: System Center 2012 - Orchestrator, System Center 2012 R2 Orchestrator, System Center 2012 SP1 - Orchestrator
The Runbook entity represents an Orchestrator runbook. The Runbooks collection includes all of the runbooks installed on the local Orchestrator environment.
Properties
The following table lists the properties of the Runbook entity.
Name | Type | Key | Description |
---|---|---|---|
CheckedOutBy |
String |
No |
Name of the account of the user that last checked out the runbook. |
CheckedOutByTime |
Date Time |
No |
Date and time that the runbook was last checked out. |
CreatedBy |
String |
No |
Name of the account of the user that created the runbook. |
CreateTime |
Date Time |
No |
Date and time that the runbook was created. |
Description |
String |
No |
Description of the runbook. |
FolderId |
GUID |
No |
GUID of the folder that the runbook is located in. |
Id |
GUID |
Yes |
Unique identifier of the runbook. |
IsMonitor |
Boolean |
No |
Specifies whether the runbook has a monitor. |
Name |
String |
No |
Name of the runbook. |
LastModifiedBy |
String |
No |
Name of the account of the user that last modified the runbook. |
LastModifiedTime |
Date Time |
No |
Date and time that the runbook was last modified. |
Path |
String |
No |
Full path to the runbook. |
Relationships
The following table lists the entities that share a relationship with the Runbook entity and the key property in each entity used to define the relationship.
Collection | Entity | Relationship | Related Entity Property | Runbook Entity Property |
---|---|---|---|---|
Activities |
Activity |
Child |
RunbookId |
Id |
Diagrams |
Diagram |
Child |
RunbookId |
Id |
Folder |
Folder |
Parent |
Id |
FolderId |
Instances |
Instance |
Child |
RunbookId |
Id |
Jobs |
Job |
Child |
RunbookId |
Id |
Parameters |
Parameter |
Child |
RunbookId |
Id |
Statistics |
Statistic |
Child |
RunbookId |
Id |
Code Samples
Getting a Runbook using C#
The following code retrieves a runbook that has a particular GUID using C#. It outputs to the console the name and ID of the runbook and whether it uses a monitor activity. This example uses a service reference named SCOService and 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 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();
// Output properties to the console
Console.WriteLine("Id: {0}", runbook.Id);
Console.WriteLine("Name: {0}", runbook.Name);
Console.WriteLine("IsMonitor: {0}", runbook.IsMonitor);
}
}
}
Getting a Runbook Using Windows PowerShell
The following code retrieves a runbook that has a particular GUID using Windows PowerShell. It outputs to the console the name and ID of the runbook and whether it uses a monitor activity. 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(),"')")
$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 the runbook
Write-Host "Name: " $output.entry.content.properties.Name
Write-Host "ID: " $output.entry.content.properties.ID.InnerText
Write-Host "IsMonitor: " $output.entry.content.properties.IsMonitor.InnerText
See Also
Concepts
Programming Using the Orchestrator Web Service
OData Queries Using the Orchestrator Web Service