Hi
I'm trying to get some information about all VM snapshots on a vCenter:
// var allSnapshots = winVcSdkConnection.getAllVirtualMachineSnapshots();
var allSnapshots = VcPlugin.getAllVirtualMachineSnapshots();
System.log("Number of Snapshots: " + allSnapshots.length);
for (i in allSnapshots) {
snapshot = allSnapshots[i];
System.log("Snapshot name: " + snapshot.Name);
System.log("VM name: " + snapshot.virtualMachineName);
System.log("Creation date: " + snapshot.createDate);
}
That workflow even works, but with one glitch: No matter which property I try, I never get the creation date of the snapshot back?
I'm not really familiar with the API Explorer, nor did I find help on the VROAPI web site.
As anybody a tipp for me?
Regards
Roman
using PowerShell may help you
Get-VM | Get-Snapshot | Select @{Label = "VM"; Expression = {$_.VM}}, @{Label = "Snapshot Name"; Expression = {$_.Name}}, @{Label = "Created Date"; Expression = {$_.Created}}, @{Label = "Snapshot Size"; Expression = {$_.SizeGB}} | Export-Csv "snapshot_details.csv"
Hello @rkuechler,
maybe this could help you:
var vms = VcPlugin.getAllVirtualMachines();
vms.forEach( function(vm) {
if (vm.snapshot) {
System.log("VM name: " + vm.name);
var snapshotTrees = vm.snapshot.rootSnapshotList;
snapshotTrees.forEach( function(snapshotTree) {
System.log("Snapshot name: " + snapshotTree.name);
System.log("Creation date: " + snapshotTree.createTime);
});
}
});
Best regards
Stefan
@sdtslmn Thank you. I already have a Powershell version which works well.
@StefanSchnell Thanks a lot, I will give this a try.