Getting Deeper Information from orchestrator via COM, part 2
Published Feb 15 2019 11:50 AM 439 Views
First published on TECHNET on May 01, 2012
In the last post , I showed you how to use PowerShell to connect to the Orchestrator COM interface for getting (and setting) various types of information. Now I’m going to run through a quick demo of how to get things like global resources (variables, counters, etc.) from COM and even modify them if you need to.

If you haven’t read the first post, go back and read it first because I won’t go over the connection process again here. I’ll assume you already know how to create a COM object and a connection handle, and I’ll just use the variable name $handle from here on out to represent that process.

The first thing to understand is that variables, counters, schedules, and computer groups are all “global resources” in Orchestrator. If you were looking through the methods available via the COM interface, this is probably why you were wondering if there was a way to access these things. These types of objects are all accessible through the GetResources , LoadResource , AddResource , and ModifyResource methods, but the method parameters might be a bit confusing until you know the structure. Since all of these different resource types are available via the same COM methods, they have to be differentiated in some way so Orchestrator knows what you want. This is done via a resource type ID and a parent folder ID.

If you wanted to get all instances of a specific type (like all variables), you would use the GetResources method like this:

$retval = $oismgr.GetResources($Handle, $ParentID, $ResourceTypeID, [ref]$outVar)

You should already know how to get $Handle and the [ref]$outVar parameters, but how do you get the ResourceTypeID or the ParentID? I’ll make it easy for you. In my script, I create a hashtable, which amounts to an enum value that I can reuse by using a property name instead of having to cut and paste Guid values everywhere. Here’s how I do it:

$ResourceType = @{}
$ResourceType.Variable = "{2E88BB5A-62F9-482E-84B0-4D963C987231}"
$ResourceType.Counter =  "{0BABBCF6-C702-4F02-9BA6-BAB75983A06A}"
$ResourceType.Schedule = "{4386DA28-C311-4A2B-8C47-3C7BB9D66B51}"
$ResourceType.Computer = "{162204B6-7F54-4CB9-A678-B94A6510BD0C}"

$ResourceFolderRoot = @{}
$ResourceFolderRoot.Runbooks = "{00000000-0000-0000-0000-000000000000}"
$ResourceFolderRoot.Variables = "{00000000-0000-0000-0000-000000000005}"
$ResourceFolderRoot.Counters = "{00000000-0000-0000-0000-000000000004}"
$ResourceFolderRoot.Computers = "{00000000-0000-0000-0000-000000000001}"
$ResourceFolderRoot.Schedules = "{00000000-0000-0000-0000-000000000006}"

Using the above, I can now specify $ResourceTypeID = $ResourceType.Variable inside my script and know I’ll always get it right. Or, I can use the hashtable values directly like this:

$retval = $oismgr.GetResources($Handle, $ResourceFolderRoot.Variables, $ResourceType.Variable, [ref]$outVar)

Formatting the XML for readability, here’s some sample output.

<Objects>
<Object>
<UniqueID datatype="string">{70DBD127-47FC-487C-BCAA-4E60BC755EFA}</UniqueID>
<Name datatype="string">Max Counter</Name>
<Description datatype="null">
</Description>
<ObjectType datatype="string">{2E88BB5A-62F9-482E-84B0-4D963C987231}</ObjectType>
<SubType datatype="null"></SubType>
<Enabled datatype="bool">FALSE</Enabled>
<Flags="" datatype="null">
</Flags>
<ASC_UseServiceSecurity datatype="null"></ASC_UseServiceSecurity>
<ASC_ThisAccount datatype="null"></ASC_ThisAccount>
<ASC_Username datatype="null"></ASC_Username>
<ASC_Password datatype="null"></ASC_Password>
<AlternateDisplayData datatype="null"></AlternateDisplayData>
<ASW_ObjectTimeout datatype="null">
</ASW_ObjectTimeout>
<ASW_NotifyOnFail datatype="null"></ASW_NotifyOnFail>
<Flatten datatype="null"></Flatten>
<FlatUseLineBreak datatype="null"></FlatUseLineBreak>
<FlatUseCSV data=""type="null"></FlatUseCSV>
<FlatUseCustomSep datatype="null"></FlatUseCustomSep>
<FlatCustomSep datatype="null"></FlatCustomSep>
<ObjectTypeName datatype="string">
Variable
</ObjectTypeName>
<Type datatype="null"></Type>
<Value datatype="string">3</Value>
</Object>

Now that you see the format of the XML, you’ll have the format required for the AddResource and ModifyResouce methods, and the resource id needed for the different methods can be seen in the UniqueID element of the XML. So, you should have the building blocks for all of the methods around the global resource objects! I will continue posting more of these examples as well as some sample script code shortly.

Version history
Last update:
‎Mar 11 2019 09:14 AM
Updated by: