VMware {code} Community
Afgdd
Contributor
Contributor

Determine the VM which are using the configure file (.vmx) in datastore

In the vCenter Server, from the vmx file inside a directory in a datastore, how to detect the VM name which are using this file by using vSphere SDK for Perl. Thanks in advance
Reply
0 Kudos
1 Reply
natxoasenjo
Enthusiast
Enthusiast

quick and dirty:

my $vmname = shift;

my $vm = Vim::find_entity_view(view_type => 'VirtualMachine', filter => {'name' => $vmname}, properties => ['name','runtime.powerState','config']);

my $config = $vm->{'config'};

print $vm->{'name'}, "\t",  $config->{'files'}->{'vmPathName'}, "\n";

Reply
0 Kudos