Contributor
Contributor

PowerVRO - how to pass complex parameters (e.g. VC:Virtualmachine) to Invoke-vROWorkflow?

Hello,

I'm trying to pass a "complex" parameter to the Invoke-vROWorkflow, but I can't figure out what to pass for the ParameterValue to get it to work. ParameterName is the name of the parameter (e.g. vm), ParameterType is "VC:VirtualMachine" I guess, but what do I need to set ParameterValue to? I've tried "vm-123" (if this is the ID of the virtual machine), and <sdk-object type="VC:VirtualMachine" href="https://vro.domain.local:8281/vco/api/org/{id}/catalog/VC/VirtualMachine/vcenter.domain.local%252Cid%253Avm-123/" id="vcenter.domain.local,id:vm-123"/>

(for vcenter name vcenter.domain.local and vRealize Orchestator name vro.domain.local) but none worked...

Thanks for any tips...

Roland

2 Replies
Contributor
Contributor

I've found a way by tweaking the New-vROParameterDefinition a little bit (see attached file)...

$sdkobject = New-Object -TypeName PSObject -Property @{

    type="VC:VirtualMachine"

    href='https://vro.domain.local:8281/vco/api/org/{id}/catalog/VC/VirtualMachine/vcenter.domain.local%252Cid%253Avm-123/'

    id='vcenter.domain.local,id:vm-123'

}

$Param1 = New-vROComplexParameterDefinition -Name 'in_VM' -Scope 'LOCAL' -Type 'VC:VirtualMachine' -sdkobject $sdkobject

Invoke-vROWorkflow -Id 'workflow-id-123456' -Parameters $Param1

This runs the Workflow with the ID 'workflow-id-123456', which has one input parameter named 'in_VM' of type VC:VirtualMachine.

Enthusiast
Enthusiast

Hi,

the function works great, thank you for posting it!

I've also found that another workaround is possible. It appears that New-vROParameterDefinition tries to convert sdk-object into string; it is possible to explicitly set the parameter value to overwrite the value set by New-vROParameterDefinition.

For example, I have sdk-object array $sdkconnection:

PS C:\gDrive\scripts\vro> $sdkconnection

Type             Value        

----             -----        

VC:SdkConnection @{sdk-object=}

When setting the $Params using this object:

$Params = @()

$Param1 = New-vROParameterDefinition -Name "filter" -Value $vm_name -Type String -Scope LOCAL

$Param2 = New-vROParameterDefinition -Name vc -Value $sdkconnection.Value -Type $sdkconnection.Type

$Param2.value is messed up - it is now vc:sdkconnection string instead of @{sdk-object}

PS C:\gDrive\scripts\vro> $param2.value

vc:sdkconnection      

----------------      

@{value=@{sdk-object=}}

So just set it explicitly:

$Param2.value = = $sdkconnection.Value

PS C:\gDrive\scripts\vro> $param2.value

sdk-object                                                                                                                 

----------                                                                                                                 

@{type=VC:SdkConnection; href=https://vro01:8281/vco/api/catalog/VC/SdkConnection/vc02/; id=vc02}

Invoke-vROWorkflow should work now.

Hope this helps!

0 Kudos