Invoke PowerShell Scripts using vRO 7.0 with a vRA 7.0 Self Service Portal Part-1.

Invoke PowerShell Scripts using vRO 7.0 with a vRA 7.0 Self Service Portal Part-1.

Invoke PowerShell Scripts using vRO, Part-1

In this blogpost i would like to share my experience of integrating vRealize Automation with vRealize Orchestrator and how seamless it is to create a custom workflow which can invoke powershell script from vRO powershell host.

In part one of this blog we would take deep dive into the crux of the solution which is vRO which allows you to create customized workflows

As we all know PowerShell is one of the most admin friendly and integrates with almost every product we have in market now.

With this integration we can create a custom self service portal using vRA and provide multitudes of service offerings which use powershell script’s and vRO powershell host in the background to perform an activity.

So lets get started with the details on the solution, Invoke PowerShell Scripts from VRO .

Prerequisites involve, a powershell host added to the vRO appliance, you should be able to see a green check-mark once the workflow successfully completes its execution. You can follow these excellent blog posts on how to add a powershell host if you have not done it yet.

Spas Kaloferov’s Blog – Adding vCO Powershell Host with account other than the default domain administrator account

DefinIT – Configuring a vRO/vCAC PowerShell host with Basic Authentication

test

Also if you are using an external orchestra-tor server make sure that you have configured it to be used with v Realize Automation.

test

Once all the pre-requisites are met, lets start with the integration script and workflows.

For my testing purpose i would be illustrating the integration by creating a workflow which invokes a powershell script which would basically uses the PowerCLI cmdlets to create a test VM based on the form input provided either through vra or vro.

Log into the vRO console, and change the view to design mode. and create a new workflow called as “Create_Test_VM”.

test

Next Click on the edit (pencil icon) workflow button present on the top end of the screen to edit the workflow.

Drag and drop the scrip-table task and Invoke an External script schema integration components into the design whiteboard in schema view.

test

Next lets start configuring each of these elements.

Click on the “Inputs” tab and define the parameters which would be fed into the powershell script.

test

Note that the password to connect to the vcenter can be declared a “Secure String” type which allows you to mask out the password with  “******” in the input form :), now that’s really cool without the use of any custom programming.

test

 

Once we define the input parameters, head over to the output tab, and create a new parameter called as “scriptarg” and move it as an attribute, this attribute will contain the format of how we pass the parameters to the powershell script.

test

Next move to the  schema view and edit the properties of the “Scriptable Task” schema object.

Click on the “Bind to workflow parameter button” and select the input parameters we defined in the previous step.

test

Once you select all the parameters, perform the similar step on the output tab and select the bind the output to the attribute “scriptarg”

test

Next click on the visual binding tab and make sure that you see a similar binding structure as depicted below.

test

Next move on to the scripting tab and define the exact arguments which would be passed on to the powershell script.

test

Note that you would need to take care of spaces between the parameters or else the powershell script would not be able to understand the parameter format.

Below script block represents the exact format of the parameters with spaces in b/w

Next edit the properties of the “Invoke an external script” schema object and select “scriptarg” as the argument to the powershell script.

test

Click on save and close the workflow.

Woaahh!, now that was a huge set of steps, but i hope that my screen-capture based step by step procedure helped you out a lot.

Next lets test the workflow , click on run, and feed in the required parameters and click on submit to Invoke PowerShell Scripts using VRO .

Note that you need to install PowerCLI  on the powershell host, also the script file during my test was placed at c:\users location in the powershell host

Invoke PowerShell Scripts using VRO

Now if you log into your vcenter server you would be greeted with your VM cloning task in action 🙂

test

Here’s the VM Cloning script which gets called.

I hope you enjoyed this blogpost on “Invoke PowerShell Scripts using VRO” and found the information useful, there is no limit to the endless possibilities we can attain with powershell an powercli in hand !!

Stay tuned for my next post where i would show how easy it is to integrate this solution with vRealize automation and offer this service to end users via a self service portal.

Do Check out my other posts on VRO, VRA and PowerShell

Please follow and like us:

Share this post

7 thoughts on “Invoke PowerShell Scripts using vRO 7.0 with a vRA 7.0 Self Service Portal Part-1.

  1. thanks, great post, got it all set up! The only thing that’s off is that password isn’t passed to the script. Any idea why this is failing?

    Reply

Post Comment