Question

I'm using the Vestris.VMWareLib API to remotely control my VMs on an ESX 5.0 server. I use the VMWareVirtualMachine.Open method to power on my virtual images. My code is written in C#. The problem is that you need to know the path to the datastore before you can power on the image, which is a bit of a pain. Is there a way to power on images using just the VM name? Thanks, John

Was it helpful?

Solution

I'm using the same technology to power on the VMs, and we have a database with the VM names. And we have a naming convenction, the VM name must unique (do not contains any other server name! f.e: abc and abcd is not allowed).

And inside the code I use the following linq to search for the actual VM by name:

List<VMWareVirtualMachine> vitualMachines = virtualHost.RegisteredVirtualMachines.ToList();
VMWareVirtualMachine serverTofind = vitualMachines.Where(vm => vm.PathName.Contains("Your server name")).First();

I hope it hepls!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top