Automate vRealize Orchestrator with PowerShell: Introducing PowervRO
For the PowerCLI book 2nd Edition I helped put together a chapter on vRealize Orchestrator. Most of the chapter was focused on running PowerShell scripts from vRO, which was something I’d had a fair bit of experience with in projects I had been on and also thought would be what most people reading would be interested in. At the end of the chapter I added a few functions using the vRO REST API to run things in vRO from PowerShell as a bit of an after-thought.
I was quite surprised when during a review phase my co-author Brian Graf suggested swapping the content of the chapter around because he thought there might be more interest in driving vRO with PowerShell, rather than having vRO execute PowerShell scripts. That didn’t quite happen due to time constraints on the book, but I kept that thought in mind having been sparked by the interest.
While putting together PowervRA I had some thoughts about expanding on what I had done in the book around PowerShell and vRO, improving what I had done for the book based on some feedback and incorporating everything we had learnt while putting that toolkit together. Thankfully Craig was up for another project and so PowervRO was born!
Over the course of the last two months or so we have put a toolkit of PowerShell functions together covering a significant portion of the vRO REST API and thankfully it has been a lot more pleasurable than what we have experienced with PowervRA ;-)
For the initial release we have 59 functions available covering a sizeable chunk of the vRO REST API. Compatibility is currently as follows:
vRO: versions 6.x and 7.0.1
PowerShell: version 4 and above is required.
You can get it from Github or the PowerShell Gallery
We have provided an install script on Github if you are using PowerShell v4. If you have v5 you can get it from the PowerShell Gallery with:
Get yourself a copy of the module via one of the above methods or simply downloading the zip, unblocking the file and unzipping, then copying it to somewhere in your**$env:PSModulePath**.
Import the module first:
You can observe the functions contained in the module with the following command:
Before running any of the functions to do anything within vRO, you will first of all need to make a connection to a vRO server. If you are using self signed certificates, ensure that you use the IgnoreCertRequirements parameter. :
You’ll receive a response, which most importantly contains an encoded password. This response is stored automatically in a Global variable: $vROConnection. Values in this variable will be reused when using functions in the module, which basically means you don’t need to get a new encoded password or server URL each time, nor have to specify it with a function – it’s done for you.
Each of the functions has help built-in, alternatively you can visit this site http://powervro.readthedocs.org
Example Use Case: Invoke a vRO Workflow with a Single Parameter
Having made a connection to vRO, it’s now time to start using some of the functions from the PowervRO module. To invoke a vRO workflow we need to determine the Id of the workflow and whether the workflow requires any parameters to be sent in order to run it correctly. Let’s look at an example of a workflow Test02.
The Id is 5af6c1fd-3d12-4418-8542-0afad165cc08
The workflow has a single parameter, a, which is a String:
The schema of the workflow is very simple, there is a single Scriptable Task which logs what the input parameter a was:
We can get the ID of a vRO workflow with Get-vROWorkflow:
and we could use that ID directly with Invoke-vROWorkflow. However, we made this easier by adding Pipeline support to Invoke-vROWorkflow, so all you need to do is this:
And here’s the result:
Example Use Case: Invoke a vRO Workflow with Multiple Parameters
So that was fine for a single parameter, but what to do if the workflow has multiple parameters? The parameter set for Invoke-vROWorkflow that we used in the previous example only supports a single parameter.
Let’s look at another example. The workflow Test03 has two inputs, a and b of different types, String and Number:
Again it has a single Schema element, which does the following:
Step forward New-vROParameterDefinition. We can use a combination of this function from PowervRO and Invoke-vROWorkflow and the Parameters parameter to submit the request to run the vRO workflow supplying multiple parameters.
To do this, create an array of parameters using New-vROParameterDefinition and supply them to Invoke-vROWorkflow:
and here’s the result of the workflow execution:
Stay tuned for more examples on using PowervRO, you can also follow @PowervROModule for updates :-)