I have something you can start with as a reference but you will need to edit it to match your needs. This was based on the vCheck powershell scripts that were ported over to vCO (code.vmware.com
As is this takes 2 inputs
(ConfigurationElement)Configuration
(Number)daysSnapshotAge
var vcVirtualMachines = Configuration.getAttributeWithKey("vcVirtualMachines").value;
var maxSnapshotTime = new Date();
maxSnapshotTime.setDate(maxSnapshotTime.getDate()-daysSnapshotAge);
System.log( maxSnapshotTime );
try {
var findAllSnapshots = function( vcVirtualMachineSnapshotTreeArray ) {
if( vcVirtualMachineSnapshotTreeArray != null ) {
for each( var node in vcVirtualMachineSnapshotTreeArray ) {
System.log( node.createTime );
if( node.createTime < maxSnapshotTime ) {
var vmObject = {"name":node.vm.name, "snapshotName":node.name, "createTime":node.createTime, "action":"deleted" };
var task1 = node.snapshot.removeSnapshot_Task(false,true);
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task1) ;
var task2 = node.vm.consolidateVMDisks_Task();
System.getModule("com.vmware.library.vc.basic").vim3WaitTaskEnd(task2) ;
results.push( vmObject );
}
if( node.childSnapshotList != undefined ) {
var childTree = node.childSnapshotList;
if( childTree != null ) {
findAllSnapshots(childTree);
}
}
}
}
}
}catch(ex){
System.log(ex)
}
try{
for each( var vm in vcVirtualMachines ) {
if( vm.snapshot != undefined ) {
findAllSnapshots(vm.snapshot.rootSnapshotList);
}
}
}catch(ex){
System.log(ex)
}
outputObject.results = results;
var output = JSON.stringify( outputObject );