In this post I will show you how execute powershell scripts as vRops actions using the vRops Management Pack for vRealize Orchestrator via powershell hosts.

In this example the scripts are stored and execute remotely using “invoke an external script” in vRO on a windows server. While my focus will be on using powershell in this post…. you will still find useful information on configuring custom workflows for the vROPS vRO MP for example: Making custom workflows visible, enabling workflows on specific ResourceKinds etc…

So to start off I will just assume you already have a vRO appliance configured in vROPS and have already run the “Add a vCenter Server instance” workflow successfully.

I will use a W2K16 server running Powershell 5.1 in this example.

So the first step is to configure WinRM so that vRO can add it as a Powershell host using the workflow “Add a PowerShell host“. Because I hate doing things manually I decided to automate the configuration instead of just running a bunch of commands… I am sure I will have to do this many times in the future so why not make a little more effort to automate it.

I wont bore you with the details…. but if you are after a one click script to setup WinRM which creates a self signed cert, locks down some settings and remove any http listeners then check out my script on Github

If you are having trouble after running my script or if you tried to setup the powershell host manually and “Add a PowerShell host” workflow keeps failing then check out this great post from Spas Kaloferov

So now that we have a working Powershell host in the vRO instance we can start working on the workflows and bringing them into vROPS.

I have built powershell scripts which interact back into vRops to make things easier for users which are not so vRops savvy… For this example I will focus on putting vRops object into Maintenance Mode by using the actions menu….

So as mentioned earlier in the post I use “invoke an external script” from vRO instead of storing the script within vRO and passing it as a script block. The reason I do this is so I always have my running code managed / up to date in a single place, it can be used / triggered by multiple methods and it allows me to store credentials for a specific service account using secure strings… This way credentials / code are never passed between vRO and the Powershell host… Instead I just pass the script path and parameters!

So I will create 2 vRO PowerShell workflow’s which will trigger my Maintenance Mode script, one workflow will put the resource into “Maintenance Window Active” and the other take it out.

Here is an expanded view of the “Enter Monitoring Blackout” workflow, tab by tab.

So now that I have the vRO workflow’s ready which I want as actions against Virtual Machines in vRops I now need to associate them with my custom package “com.vMan.vRops.custom” so that vRops can import and use the associated workflows later on.

Search for your custom Package under Assets in vRO and edit it.

Shift over to Content, click ADD

Search for the workflow, select the checkbox and click ADD and then save the package.

So now that we have the workflows configured in the custom package we now need to tell vRops to import that package along with the default ones.

Head over the the vRops GUI, find the vRO instance configured in the vRO MP which you want to import the package for, under the Actions menu click Configure Package Discovery

Enter the custom vRO package name at the bottom of the list and click Begin Action.

Wait a few minutes and refresh the vRO instance object, you should now see the custom package listed.

Once the package has been scanned in we need to enable the workflows on the desired resource kinds within vRops, in this example it will be VirtualMachines

Select Create/Modify Workflow Action on vCenter Resources from the Action dropdown

Currently these workflows are not associated with anything… we are now going to add them to the VirtualMachine resourceKind.

Check the boxes, select Virtual Machine from the drop down and select Add from the Operation drop down…. then click Begin Action

After waiting a few minutes we will now navigate to a Virtual Machine within vRops and we can see the new Actions listed!!

Running the action will auto populate the vROPS Virtual Machine, Clicking Begin Action will kick off the workflow.

Checking Workflow Runs in vRO

WOOOOOOOOOWOOOOOOOOO and there you go, that’s how to add your own custom Package / workflows to vRops!!

You might experience the error “The computer must be trusted for delegation” the first time when executing a PowerShell workflow…. don’t forget to check if delegation is allowed / configured on the computer account in Active Directory users and computers. It’s possible you have a restriction in place or “Do not trust this computer for delegation” is set by default.

Hope you found this helpful

vMan