The Orchestrator 2012 Beta is barely “out of the oven” and I have some fun PowerShell stuff for you to play with using the new REST-based web service. Working with web services from PowerShell is rather new to me, but I was surprised how easy it was to create a few functions that let me browse around the contents of the data in Orchestrator using the web service.
Get the PowerShell script for all of this here
First of all, I created a function to do the actual connection to the web service and querying it. Thanks to another smart person for coming up with this part (
see my previous post where I talked about this
). This function is called
, This is a generic function that allows me to call virtually any REST-based web service. On top of that, I have another function called
The Query-SCOService function simply formats the URI properly for the SCO web service (which you could do yourself with the Query-RestService function). If I call this function and don’t provide a query, I get the same thing I’d get if I typed the default web service URL into a browser:
(2) Pass this xml into the
ConvertTo-SCOObject -XmlFeed $xmlfeed
The resulting output is one or more objects that can then be used for further querying. For example, if I want to get a list of all Instances of a job that do not have a status of “completed” and show only their IDs, I could do this:
Do you see how I am utilizing the properties as extensions to the base URI? Cool, huh?
I whipped this whole thing up in a couple of hours. I encourage you to play around with it and try new things. When we ship Orchestrator 2012, we’ll have an official, shipping PowerShell interface that’s built on top of the web service, and it will definitely be much better than this simple script, but between now and then this is something to get you thinking about how useful PowerShell and the new web service are together.