I have tree of snapshot like this
snap1
|
----------|----------|
snap2 snap3
|--------------|
snap4 snap5
How can I get all paths to the leafs ot this tree ?
Like:
/snap1/snap2
/snap1/snap3/snap4
/snap1/snap3/snap5
Thank you very much.
This is a quick-and-dirty script that should give you the snapshot paths
function Get-SnapList{ param($snap,$path) $path += "/" + $snap.Name if($snap.ChildSnapshotList){ $snap.ChildSnapshotList | %{ Get-SnapList $_ $path } } $path
} $vmName = "MyVM"
$vm = Get-View -ViewType VirtualMachine -Filter @{"Name"=$vmName} if($vm.Snapshot){ $report = $vm.Snapshot.RootSnapshotList | %{ Get-SnapList $_ "" } } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Perhaps not exactly what you are looking for but my UML diagram your VM, vdisks and snapshots post maps the snapshots graphically in an UML: diagram.
Seriously, you can use the RootSnapshotList and a recursive function to list the tree structure.
That code is available in the UML post.
Let me know if you want a text output only version ?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I need text only version, but I think I would found something in your example.
This is a quick-and-dirty script that should give you the snapshot paths
function Get-SnapList{ param($snap,$path) $path += "/" + $snap.Name if($snap.ChildSnapshotList){ $snap.ChildSnapshotList | %{ Get-SnapList $_ $path } } $path
} $vmName = "MyVM"
$vm = Get-View -ViewType VirtualMachine -Filter @{"Name"=$vmName} if($vm.Snapshot){ $report = $vm.Snapshot.RootSnapshotList | %{ Get-SnapList $_ "" } } $report
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thank you very much.