/**
* Returns information of all VMs.
*
* Orchestrator > Administration > Inventory > vSphere vCenter Server >
* vCenter > Datacenters > Datacenter > vm
*
* Checked with release Aria Automation 8.12.0, 8.16.0, 8.18.0 and
* VCF Automation 9.0.0
*/
// Important hint
// Requests for all VMs without a filter (query = null) should be
// avoided with both methods, an XPath filter should be used.
// Search in the internal database or local cache of the Orchestrator
// for all VM objects
var vms = Server.findAllForType("VC:VirtualMachine", null);
vms.forEach( function(vm) {
System.log(vm.name);
// System.log(vm.displayName);
System.log(vm.hostName);
System.log(vm.id);
// System.log(vm.vimId);
System.log(vm.sdkId);
});
// Search in all connected vCenter servers for all VM objects
var vms = VcPlugin.getAllVirtualMachines(null, null);
vms.forEach( function(vm) {
System.log(vm.name);
// ...
});
// Examples how to us an XPath query
var xPath = "xpath:name='vm-0001'";
// var xPath = "xpath:starts-with(name, 'v')"
var vms = VcPlugin.getAllVirtualMachines(null, xPath);
|