#!/usr/bin/perl -w use strict; use warnings; use Data::Dumper; use VMware::VIRuntime; my %opts = ( vm => { type => "=s", help => "Name for the VM", required => 1, }, ip => { type => "=s", help => "Name for the IP", required => 1, }, ); Opts::add_options(%opts); Opts::parse(); Opts::validate(); Util::connect(); my $ip_address = Opts::get_option('ip'); my $vmname = Opts::get_option('vm'); my %filter=(name=>$vmname); my $vm = Vim::find_entity_view(view_type => 'VirtualMachine',filter=>\%filter); foreach my $ip (@{$vm->guest->net->ipConfig->ipAddress}) { my $ip_address = Opts::get_option('ip'); my $ipadd = ref $ip; if ($ipadd eq $ip_address) { print "Found $ip for $vmname \n"; } # } } Util::disconnect();