Create a vRO script environment for PowerCLI with additional modules

With vRealize Orchestrator 8.1 or higher it is possible to use PowerShell, NodeJS, and Python for tasks in vRealize Orchestrator workflows in addition to the traditional Javascript. As PowerShell support was added, it wasn’t necessary to add a PowerShell host to run PowerShell scripts anymore.

We can now use the following runtimes in our action and workflow scripts:

  • Python 3.7
  • Node.js 14
  • PowerCLI 11/Powershell 6.2
  • PowerCLI 12.3.0/Powershell 7.1

OOTB, the PowerCLI runtime includes PowerShell and the following modules:

  • VMware.PowerCLI
  • PowerNSX
  • PowervRA

But to use additional modules in these polyglot scripts, we had to include dependencies by adding them as a ZIP package, which was a quite tedious work.

With vRealize Orchestrator 8.8 or higher, we can now add modules and libraries for use in our vRealize Orchestrator scripts as dependencies directly from the vRealize Orchestrator Client.

In this example, we’ll investigate how to create a script environment with an additional module for PowerShell.

Recently, I needed to export collected data in XLS format using the PowerCLI 12 script environment.

Working with Excel in PowerShell can be best solved by using the awesome ImportExcel module, which is available from the PowerShell gallery at https://www.powershellgallery.com/packages/ImportExcel/7.4.1.

To access the module functions in vRO, we use the following procedure:

  1. Log in to the vRealize Orchestrator Client.
  2. Navigate to Assets > Environments, and click New Environment.
  3. Under the General tab, enter the name for the environment: PowerCLI12_with_modules
  4. Select the Definitions tab.
  5. Under Runtime Environment, select: PowerCLI 12 (PowerShell 7.1)
  6. Edit the memory limit to: 512 MB
  7. Under Dependencies, click Add, and enter the following values
    1. Name: ImportExcel
    2. Version: 7.4.1
    3. Click Add.
  8. To finish creating the new script environment, click Create.
  9. After the environment is created, select the Download Logs tab on the environment editor page and validate that the ImportExcel module is downloaded successfully.

We can now use the created environment in workflow scripting tasks (or ABX actions) by selecting the environment from the Runtime Environment drop-down menu of your workflow scripting schema element or vRealize Orchestrator action.

Previous

Introducing VMware Aria

Next

vRA lifecycle extensibility with vRO workflows

3 Comments

  1. Jean-Philippe Martin

    Interesting… what could be “imported” related to node.js ?

Leave a Reply

Your email address will not be published. Required fields are marked *

All your base are belong to us.