Share via


Folder

Applies To: System Center 2012 - Orchestrator, System Center 2012 R2 Orchestrator, System Center 2012 SP1 - Orchestrator

The Folder entity represents an Orchestrator folder, and the Folders collection includes all of the folders in the local Orchestrator environment. You can traverse the folder structure by following the Parent and SubFolders collections.

Properties

The following table lists the properties of the Folder entity.

Name Type Key Description

CreatedBy

String

No

Name of the account of the user that created the folder.

CreateTime

Date Time

No

Date and time that the folder was created.

Id

GUID

Yes

Unique identifier of the folder.

LastModifiedBy

String

No

Name of the account of the user that last modified the folder.

LastModifiedTime

Date Time

No

Date and time that the folder was last modified.

Name

String

No

Name of the folder.

ParentId

GUID

GUID of the folder's parent folder. If the folder is at the top level, then this property holds an empty GUID.

Path

String

No

Full path to the folder.

Relationships

The following table lists the entities that share a relationship with the Folder entity and the key property in each entity used to define the relationship.

Collection Entity Relationship Related Entity Property Folder Entity Property

Parent

Folder

Parent

Id

ParentId

Subfolders

Folder

Child

ParentId

Id

Runbooks

Runbook

Child

FolderId

Id

Code Samples

The following samples retrieve the runbooks in a particular folder. These samples assume that the folder does not have more runbooks than the maximum entries returned on a single page, which is 50 by default. For more information see Paging in Orchestrator Web Service.

Getting the Contents of a Folder Using C#

The following code retrieves all runbooks in a particular folder using C#. 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 FolderContents
   {
      public static void Main()
      {
         Guid folderId = 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 SCOService.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 runbooks from the folder
         IEnumerable<Runbook> runbooks = from rbk in context.Runbooks where rbk.FolderId == folderId select rbk;

         // Output properties of each runbook to the console
         foreach (Runbook rbk in runbooks)
         {
            Console.WriteLine("Id = {0}, Name = {1}, IsMonitor = {2}", rbk.Id, rbk.Name, rbk.IsMonitor);
         }      
      }
   }
}

Getting the Contents of a Folder Using Windows PowerShell

The following code retrieves all runbooks in a particular folder using Windows PowerShell. 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 folder we want to get
$runbookId = "00000000-0000-0000-0000-000000000000"

# Create the request object
$url = -join ("http://server01.contoso.com:81/Orchestrator2012/Orchestrator.svc/","Folders(guid'",$folderId.ToString(),"')/Runbooks")
$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 activity
foreach ($runbook in $output.feed.entry)
{
    Write-Host "Id: " $runbook.content.properties.Id.InnerText
    Write-Host "Name: " $runbook.content.properties.Name
}

See Also

Concepts

Programming Using the Orchestrator Web Service
OData Queries Using the Orchestrator Web Service