I wrote this code in Orchestrator to get a VC:VirtualMachine object based on a vmName string.
//Query format for the vCenter plugin Server. The '(?i)' makes the query case-insensitive.
var query = "xpath:matches(name, '(?i)" + vmName + "')";
//Search for all VMs based on the vmName input.
//Note getAllVirtualMachines() returns an array.
var vmsFound = VcPlugin.getAllVirtualMachines(null, query);
return vmsFound;
This works, but it gets one and only one VM. If I input string "project1database01" it will return the corresponding type of VC:project1database01.
However, it doesn't match partial names. If input "project1", "project1*", or *database*", the code finds nothing.
I'm not sure what version of xpath Orchestrator uses, or any quirks of the getAllVirtualMachines() method. How can I get the code to find all virtual machines that contain the input string?