VMware {code} Community
Leafy
Contributor
Contributor

Is it possible to retrieve a VirtualMachine MOR with a VM Name?

I found code that can do this by reading through all of the Virtual Machines, but is it possible to specifically point to a Vitual Machine with the VM name?

Thanks!

0 Kudos
1 Reply
arpitmpatel13
Enthusiast
Enthusiast

Yes, it is possible to get MOR with VM name.

Check following function:

appUtil.getServiceUtil().getDecendentToRef()

You can use it as follows:

vmmor = appUtil.getServiceUtil().getDecendentToRef(mor for root /you can provide NULL/) ,

type of system /*for Host use --host for VM use --vmname*/,

apputil.get_options/vm name or host name/ );

vmmor is object of ManagedObjectReference

appUtil is object of AppUtil

Thanks

Please mark if helpful