Why doesnt this work - To find ipAddresses from all VMs on and ESXi host?
#!/usr/bin/perl -w
use strict;
use warnings;
use VMware::VIRuntime;
use VMware::VILib;
# validate options, and connect to the server
Opts::parse();
Opts::validate();
Util::connect();
my $vm_view = Vim::find_entity_views(view_type => 'VirtualMachine');
foreach my $vm (@$vm_view) {
my $vm_name = $vm->summary->config->name;
my $nets= $vm->guest->net;
foreach my $net(@$nets) {
print $vm_name . "\n" . $net->{ipAddress} . "\n";
}
}
Util::disconnect();