Find Virtual Machine MOref
Use the PropertyCollector to get a managed object reference for a virtual machine named in the command line.
Given the name of a virtual machine, this function retrieves references to all of the virtual machines in the datacenter and looks for a match to the specified name.
Prerequisites
For this task you need:
- A virtual machine name is
referenced by the String variable
vmName
. - An authenticated Web Services session with the vSphere server that manages the virtual machine.
- A VimPort binding provider is
referenced by the variable
methods
, which is attached to the vSphere server connection context. - The ServiceInstance content is
referenced by the variable
serviceContent
. - The ViewManager object is
referenced by the variable
viewMgr
. - The PropertyCollector object is referenced by the variable
pCollector
.
Procedure
What to do next
Given the MOref of the named virtual machine, you can use the PropertyCollector to retrieve ia MOref to its parent folder, which you will need to clone the virtual machine.