Hi Ken,
The code below illustrates how you can delete multiple snapshots of a VM with the same name in a single go.
#!/usr/bin/perl -w
#Copyright (c) 2007 VMware, Inc. All rights reserved.
use strict;
use warnings;
use FindBin;
use lib "$FindBin::Bin/../";
use VMware::VIM2Runtime;
use VMware::VILib;
$Util::script_version = "1.0";
Opts::parse();
Opts::validate();
Util::connect();
display_servertime();
Util::disconnect();
sub display_servertime ); # Get the VM of your choice by entering the VM name here
unless ($vm_view)
my $ss = $vm_view->snapshot->rootSnapshotList;
foreach (@$ss) {
deleteSnapshot($_);
}
}
sub deleteSnapshot {
my ($snaps) = @_;
print "\nAnalyzing Snapshot: ". $snaps->name;
if ($snaps->name eq 'delSnap') { # Replace the name of the snapshot you want to delete
print "\nDeleting the snapshot delSnap....";
eval {
Vim::get_view(mo_ref => $snaps->snapshot)->RemoveSnapshot (removeChildren => 0 );
};
if ($@)
}
if (defined $snaps->childSnapshotList) {
my $child = $snaps->childSnapshotList;
foreach (@$child) {
deleteSnapshot($_);
}
}
}
I hope this was what you were looking for.
~ Sidharth