i have schedule workflow for reset all vm's one time in week,
i take all vms from "vm folder" but i want to exclude vms from list of "array of virtualMachine".
is it possible?
Hi Robert_BE,
both are arrays, so you have to compare them and if the names are not eqal you can push them in a new array as base for your reset. Here is how:
Comparing two arrays in Javascript - Stack Overflow
Best regards
Christian
Cristian tank you for your response,
i dont compare between 2 arrays becuse i get all vm from folder and after i use "for each" command,
so i want to check if one VM belong to list of vms.
You can create ArrayList containing "MOR" (Managed Object reference) of each VM. Take each MOR one by one out & if it is of the Vm that you want to exclude, just straightway skip any operation on that VM.
Let me know if you need any help.
Hi,
"VMS" is aray of all Virtual machine,
"exlude" is array of 3 vm's,
I mean something like this:
for each var vm in vms {
if (??? != ????) {
Task=system.getModule("com.vmware.library.vc.vm.power").resetVM(vm)
}
so what is the command instead (??? !=???) for check if vm belog to "exclude" ?
a really simple Solution would be:
https://www.vmware.com/support/orchestrator/doc/vco_vsphere55_api/html/VcVirtualMachine.html
i hope every VM in your environment has a unique name...
//we go through each VM
for(var i in VMS)
{
//each new VM is per default not excluded
var isExcluded = false;
// check against exclude array
for(var j in exclude)
{
if(VMS[i].name == exclude[j].name)
{
isExcluded = true;
}
}
//check if VM is now excluded
if(isExcluded)
{
System.debug(VMS[i].name +" is excluded from restart");
}else
{
System.getModule("com.vmware.library.vc.vm.power").resetVM(VMS[i])
}
}
out of my brain .. not tested.