Sergey Nivens - Fotolia


Get started with vRealize Orchestrator with PowerCLI

You can use PowerCLI to automate tasks in vRealize Orchestrator 8.1. Use cmdlets through the Scriptable Task feature or from a workflow in vRealize Orchestrator.

VRealize Orchestrator 8.1 now enables you to run scripts in other languages, including PowerCLI. This simplifies task automation across a vSphere environment.

Previous versions of vRealize Orchestrator only supported JavaScript as a scripting language; you could only access commands via JavaScript. This complicated certain tasks that require other languages, such as integration with Microsoft products, which require PowerShell. However, this did not prevent admins from successfully developing customized workflows.

Scriptable Tasks vs. actions

When you run a PowerCLI script in vRealize Orchestrator, you can run it as either a Scriptable Task or an action. Actions represent static script functions that you can drag into a workflow. You can reuse code you use in actions over and over, even inside Scriptable Tasks. You can organize actions into modules, which represent groups of specific actions.

When you run a workflow with Scriptable Tasks, the workflow executes these tasks in each new execution runtime as a distinct workflow item.

How to run a PowerCLI script in vRealize Orchestrator

You could previously execute PowerShell code from vRealize Orchestrator, but you could not natively run that script in a vRealize Orchestrator server. The system required you to set up a Windows host to run the script for you.

vRO 8.1 PowerShell plugin workflow
You can use a plugin to create a specific workflow that enables you to run a PowerShell script.

The interpreter for your selected scripting language processes any scripts that you place into a Scriptable Task on the server. This eliminates the requirement for additional hosts.

vRO 8.1 PowerCLI language choice
VRealize Orchestrator 8.1 still supports JavaScript as a language, but it now supports PowerCLI, Node.js and Python natively.

You likely use PowerCLI more often than Node.js or Python. PowerCLI -- a PowerShell extension from VMware -- enables VMware administrators to directly invoke useful commands for a VMware environment, such as creating or configuring VMs at scale.

PowerCLI scriptable task default
When you create a new scriptable task with PowerCLI, it defaults to code that you can run immediately; from there, you can use PowerCLI cmdlets.

To test this feature, begin by creating a simple script that reports all VMs that have a snapshot.

Use the get-vm | get-snapshot command, and then format it to display the relevant fields:

get-vm | get-snapshot | format-table created,VM,@{label="Size in GB";Expression={"{0:N2}" -f (

If your vCenter server has a self-signed certificate, you might fail to create a connection. Input a command to instruct PowerCLI to ignore any invalid certificates, such as:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCeip:$false -Scope Session -Confirm:$false

Then, connect to your vCenter server with your credentials with the command Connect-VIServer. Because this command runs without user interaction, input parameters for server, user and password:

Connect-VIServer -Server $inputs.server -Protocol https -User $inputs.user  -Password $inputs.password

If you run the task from a Scriptable Task workflow, it might show an error message indicating you have run out of memory. To avoid this error, ensure you have more than 64 MB of memory available before executing these tasks.

Action elements

Action elements enable you to reserve a certain amount of RAM when you execute tasks through PowerCLI. You cannot do this with a Scriptable Task, but you can work around that issue by writing your script in an action and then executing the action from a workflow.

For example, you can reserve 512 MB RAM for the Runtime Limit under properties.

vRO 8.1 PowerCLI action
Write a script to reserve RAM in an action, then execute that action from a workflow to work around the limitations of Scriptable Tasks.

When you execute an action from a workflow, vRealize Orchestrator logs the action.

vRO 8.1 snapshot report result
VRealize Orchestrator can log an action such as reporting a list of VMs with snapshots.

Dig Deeper on VMware ESXi, vSphere and vCenter

Virtual Desktop
Data Center
Cloud Computing