VirtualMachine->summary->guest->hostName seems to be giving me the DNS name of the VM, not the hostname... Is there a way I can get the actual hostname? Thanks!
Are you looking for the host name that is running this VM? This information can be fetched from VirtualMachine->runtime->host property. This will give you a managed object reference to the host. You can then retrieve the "name" property from the MOR to get the name of the host.
Hope this information is helpful.
Here ya go... From my CGI script at: http://communities.vmware.com/thread/202882
Create the managed object reference from the two variables we split up earlier.
my $my_moref =
ManagedObjectReference->new( type => $VMobjtype, value => $VMname );
Get the specific VM view
my $vm = Vim::get_view( mo_ref => $my_moref );
#
Get the DNS Hostname of the VM.
my $DNShostname = $vm->summary->guest->hostName;