VMware {code} Community
Lab_Rat_Chris
Contributor
Contributor
Jump to solution

How do I get a Virtual Machines DNS name using the VI Perl Tool Kit???

I have a bit of code which I have included below. This works fine for getting the virtual machines common name(Earth). I am looking for the proper value of the vm to look at to gain access to it's dns name(Earth.SolarSystem.com).

Has anyone done this? If so how?????

-


Code----


my $vm = Vim::find_entity_views(view_type => "VirtualMachine");

foreach (@$vm) {

eval {

my $vmname = $_->name;

  1. Do Something

}

}

Thanks

Chris

0 Kudos
1 Solution

Accepted Solutions
kri-2
Hot Shot
Hot Shot
Jump to solution

Hi,

try this one:

my $vm = Vim::find_entity_views(view_type => "VirtualMachine");

foreach (@$vm) {

print $_->\{guest}->\{'hostName'} ;

}

View solution in original post

0 Kudos
2 Replies
kri-2
Hot Shot
Hot Shot
Jump to solution

Hi,

try this one:

my $vm = Vim::find_entity_views(view_type => "VirtualMachine");

foreach (@$vm) {

print $_->\{guest}->\{'hostName'} ;

}

0 Kudos
tmilner
Enthusiast
Enthusiast
Jump to solution

This will only work if you have VMware Tools installed.

Tom

0 Kudos