Have a look at the vim3WaitDnsNameInTools action. The following code allows to get the DNS name attributed to a VM via the VMware tools.
if (vm.guest != null) {
if (vm.guest.toolsStatus == VcVirtualMachineToolsStatus.toolsOk || vm.guest.toolsStatus == VcVirtualMachineToolsStatus.toolsOld) {
if (vm.guest.guestState == "running") {
hostname = vm.guest.hostName;
Alternatives would be to use :
- guest operation workflows (vCO 5.1 ) to run a command in the guest to retrieve its DNS name.
- System.resolveIpaddress() (but then you need to get the VM IP address via the tools, you'd better get its DNS name in the first place).
Christophe.