VMware {code} Community
samsvmware
Enthusiast
Enthusiast

listing the VM Templates

is ter any perl api(script) for listing the VM Templates in a vcenter web client...

Reply
0 Kudos
1 Reply
stumpr
Virtuoso
Virtuoso

Not tested, but should do the trick baring any typos (if you need more properties than name b/c you're looking for other data, either remove the properties => argument or add the values you want) -

#!/usr/bin/perl

use strict;

use warnings;

use VMware::VIRuntime;

Opts::parse();

Opts::validate();

Util::connect();

my $templates = Vim::find_entity_views( view_type => 'VirtualMachine', filter => { 'config.template' => 'true' }, properties => [ 'name' ] );

foreach my $template (@{$templates || [ ]}) {

     print "Tempate: " . $template->{'name'} . "\n";

}

Util::disconnect();

Reuben Stump | http://www.virtuin.com | @ReubenStump