Importing newer PowervRA in a vRO PowerCLI action

Importing newer PowervRA in a vRO PowerCLI action

vRO 8.1 added support for multi language/multi runtimes script executions, aka Polyglot. One of these is PowerShell and PowerCLI. Together with that it bundles PowervRA, a PowerShell module to
interact with vRA's APIs. And since at the time of releasing vRO 8.1 the latest version of PowervRA was 3.6.0 this is the one that you can use out of the box. However as of today there have been updates to this module, and especially there is a new major version 4.x that adds support for vRA 8. You may have noticed that if you try to include the latest version of it, your script will still use the one coming from vRO.

In this document we will cover how you can update the PowervRA module to newer versions.

1. Bundle the desired version of PowervRA. To do this, we will do the standard procedure to bundle external modules:

# create a directory for our files and open it
mkdir myproject && cd myproject

# create a modules directory, where external modules will be saved (and loaded by vRO)

mkdir Modules

# install PowervRA 4.1.1, or choose any other version, omit -RequiredVersion for latest

pwsh -c "Save-Module -Name PowervRA -RequiredVersion 4.1.1 -Path ./Modules/"

2. Create the handler script that will use the module, called handler.ps1

function Handler($context, $inputs) {
   Import-Module -Name PowervRA -RequiredVersion 4.1.1 # Explicitly import version 4.1.1

   $Password = (ConvertTo-SecureString -String "{PASS}" -AsPlainText -Force)
   $con = Connect-vRAServer -Server {VRA} -Username "{USER}" -Password $Password -IgnoreCertRequirements

   Write-Host $con.APIVersion
   return @{status = 'done'


As you see, everything is pretty much the same as when we include any 3rd party dependency. The cornerstone really is the explicit Import-Module on line 2, it tells PowerShell to use the PowervRA module that we bundled with our script, instead of the module that vRO comes with.

For additional sample scripts of PowerShell,Python and Node.JS you can checkout here vro-polyglot-scripts - Samples - VMware {code}

Version history
Revision #:
1 of 1
Last update:
‎10-15-2020 08:50 AM
Updated by: