Highlighted
Enthusiast
Enthusiast

Execute PS script + having the output into workflow parameter values

Hi,

I have PS script that returns all vms owned by some user.

I want to know if it possible to have the script executed when entering the workflow request (or at any other point) +having the output of the script somehow appear into vra parameter values (dynamically)...

Any suggestions ?

Thanks in advance.

0 Kudos
9 Replies
Highlighted
Expert
Expert

I'll have to assume a few things here so my answer makes sense

1. You're using the vRA Service Portal

2. You want to build a custom form

3. You want the custom form to have a drop-down with a list of VMs owned by the current user

4. You are using a PowerShell script to list the VMs

5. You want the VM names output by the script to be displayed in the drop-down using ExternalValues

OK so far?

I've done stuff like the above before and it can be a bit messy and slow. It IS DEFINITELY possible though.

To get the drop-down values you would need to write an action which calls your PowerShell script and returns the VM list as an Array of strings. Note that the script invocation can be quite slow as the E2E conversation is from vRA --> vRO --> PowerShell Remote --> PowerShell script --> VC and then all the way back again.

Your script or the action would need to format the VM list in a way that can be easily tokenized by vRO (either CSV or perhaps JSON?) and then vRO needs to process that result into an Array of string values to return.

Once you have all of that sorted out you would need to be aware that the script will be run EVERY TIME the form is loaded which may or may not be desirable (how many users will be able to access the form at the same time?)

As a last note, if you're using vRA and all the user VMs are managed by it, you don't need PowerShell at all - vRA keeps an inventory of the VMs and each has details of the current owner in it's attributes. Perhaps consider going that way instead of using PowerShell to do this?

0 Kudos
Highlighted
Enthusiast
Enthusiast

Hi,

All your assumptions are correct.

Let me just make it clearer im not talking about VC but VCD (vCloud Director)

I want to grab all user vApps and list them in a vRA parameter values.

The workflow is destined to run by approx ~15 people a day, is there any better way to accomplish these (better run time) ?

thanks

0 Kudos
Highlighted
Expert
Expert

Why not access the vCD REST API then? I'd imagine the PS approach is most likely just a shim to query that anyway. Or use the vCD plugin in vRO to get them?

You can browse the Plugin class docs here - vRO API Explorer by Dr Ruurd and Flores of ITQ

Also, is VCD a provisioning endpoint for vRA? If so then I'd have expected the VMs/vAPPs available on it listed in the Inventory anyway?

0 Kudos
Highlighted
Enthusiast
Enthusiast

You have some good points... I will definitely check them

Thanks!

0 Kudos
Highlighted
Enthusiast
Enthusiast

Hi again,

I have installed the plugin and added my vcd host to vro.

I cant seem to find a way to get all user vapps names from certain organization with the plugin

I have powershell script who is doing what I have mentioned, but how do I integrate both plugin & the powershell script

$userVapps = Get-CIVApp -Org $vcdOrg -Owner $USER

any idea?

Thanks

0 Kudos
Highlighted
Expert
Expert

I wonder if you have a permissions problem there? The user vRO is connecting to vCD as - do they have permission to see all vApps in the vCD portal?

0 Kudos
Highlighted
Enthusiast
Enthusiast

No, no permissions problem.

My permission is system administrator.

And my user role has everything on true.

Even with API Rest there is no option of getting all vapps owned by specific owner.

0 Kudos
Highlighted
Expert
Expert

You might have to traverse the vApps for each/all vDCs to get that information?

pastedImage_0.png

The above is for AdminVdc

pastedImage_1.png

This one is for non-admin Vdc

If a user can have vApps in both then you need to run multiple vApp queries then filter by the owner attribute and aggregate?

0 Kudos
Highlighted
Enthusiast
Enthusiast

I will check it!

Thanks a lot!

0 Kudos