Hi all
I would like to search the VMs whose haven't a specific custom property defined on it.
Anyone have a idea to do that in only one Odata query ? (to avoid looking 4000 Vms one by one)
I found this link to find the Vms by custom property name and value (https://automate-it.today/vro-code-finding-virtualmachines-custom-property/)
But in my case, it's a little bit different, because i want to get VM name if a custom property not exist.
Thanks for your help
Jacques
Change your query to:
var filter = "not(VirtualMachineProperties/any(p: p/PropertyName eq '" + propertyName + "')) and IsManaged eq true";
That will give you all the entities that are managed by this vRA and which do not contain a property with that name. You can then get all the names with:
const names = machines.map(function(machine) { return machine.getProperty("VirtualMachineName"); });
Change your query to:
var filter = "not(VirtualMachineProperties/any(p: p/PropertyName eq '" + propertyName + "')) and IsManaged eq true";
That will give you all the entities that are managed by this vRA and which do not contain a property with that name. You can then get all the names with:
const names = machines.map(function(machine) { return machine.getProperty("VirtualMachineName"); });