VMware Cloud Community
rkuechler
Enthusiast
Enthusiast

Getting some VM snapshot informations from a vCenter?

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

 

 

0 Kudos
3 Replies
sdtslmn
Enthusiast
Enthusiast

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"

https://scriptigator.com/2020/02/19/getting-snapshot-details-of-virtual-machines-get-snapshot-cmdlet...

StefanSchnell
Enthusiast
Enthusiast

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


More interesting information at blog.stschnell.de

rkuechler
Enthusiast
Enthusiast

@sdtslmn Thank you. I already have a Powershell version which works well. 

@StefanSchnell Thanks a lot, I will give this a try.

0 Kudos