VMware Cloud Community
Regan_Waters1
Contributor
Contributor

Running a workflow from powershell

Hello,

We have a number of custom workflows in Orchestrator to build a VM. If we start the workflow in Orchestrator provide all the imputs this works fine. We are now attempting to run this workflow from a powershell script that provides all the required imputs. I have tested the script on the "Create a simple XML document" and this worked fine. When I run the script against our "Test Deploy" workflow it starts the workflow then errors straight away with Cannot convert to object , reason : null. I can not figure out what is wrong.

If I query the workflow these are the imputs it expects

name : folder
type : VC:VmFolder

name : name
type : string

name : host
type : VC:HostSystem

name : pool
type : VC:ResourcePool

name : nic1Network
type : VC:Network

name : MemoryMB
type : number

name : CPUs
type : number

name : clientName
type : string

name : TemplateVM
type : VC:VirtualMachine

I have attached the script in hope someone may be able to help resolve this issue.

Cheers,

Regan.

0 Kudos
2 Replies
tschoergez
Leadership
Leadership

Hi!

Unfortunately, it's not that easy: You only can place basic input types like a string, number or boolean via the plan value.

For Inventory-Objects, like a VirtualMachine or a HostSystem you had to specify the vCO-internal ID. To get this ID now, you have to call the findXXXX()-Methods of the SOAP-Webservice before (see the flowchart in the documentation:http://pubs.vmware.com/vsphere-50/topic/com.vmware.ICbase/PDF/vcenter-orchestrator-42-develop-web-se... page 10).

For this there is an example in the samples-package, implemented in Java (but you should be able to see the idea), see some introduction here:

http://www.vcoportal.de/category/integrate-vco/external-workflow-calls/

If all that seems to complicated (yes it is 🙂 ), you could...

... transfer the logic to get the IDs of the object in the system which generates the XML (e.g. there are some methods to "translate" vCenter Managed Object IDs (MOID) to vCO-Inventory Object IDs, you can find them in the SdkConnection-Class.

... or you could implement the logic to find the objects for a given name into the workflow (as first step). Than your workflow only needs easy to provide plain strings as input. The xpath-filters for the getAllXXXXX()-Methods of a SdkConnection might help here.

(There are a bunch of discussions and examples about this here in the forums: http://www.google.de/search?q=xpath+orchestrator+site%3Acommunities.vmware.com )

Cheers,

Joerg

Regan_Waters1
Contributor
Contributor

Thanks Joerg. I need to do a lot more reading and see if I can work it out.

Regan.

0 Kudos