Delete All Snapshots on KVM with Virsh
- 
 With a quick command line, you can automate removal of all snapshots associated with a virtual machine. While you could write the VM name into the command line, you can also, as in my example, set a variable with the name of the VM so that a standard removal command can be used. let vm="myVMname" for snapshot in $(virsh snapshot-list $vm | tail -n +3 | head -n -1 | cut -d' ' -f2); do virsh snapshot-delete $vm $snapshot; doneIt's not very commonly that you would want to automatically remove all snapshots from a VM in this manner. If this becomes a regular part of your routine, making this into a saved script would likely make sense. 
- 
 If you want to automate this to remove all snaps from all VMs, you can just run this one command... for vm in $(virsh list --all | tail -n +3 | head -n +1 | cut -d' ' -f7); do for snapshot in $(virsh snapshot-list $vm | tail -n +3 | head -n -1 | cut -d' ' -f2); do virsh snapshot-delete $vm $snapshot; done; done
- 
 And in PowerShell: Get-VM VMName | Remove-VMSnapshot -Name *
- 
 @obsolesce said in Delete All Snapshots on KVM with Virsh: And in PowerShell: Get-VM VMName | Remove-Checkpoint -Name *Well, that's for Hyper-V and isn't PowerShell. PowerShell on KVM won't work that way as those are Hyper-V local commands being called from PowerShell, and not PowerShell itself. 
- 
 @obsolesce said in Delete All Snapshots on KVM with Virsh: And in PowerShell: Get-VM VMName | Remove-Checkpoint -Name *My Hyper-V hosts do not have this command. How do you get this to work? I can't find any Microsoft documentation on it, either. 
- 
 @scottalanmiller said in Delete All Snapshots on KVM with Virsh: @obsolesce said in Delete All Snapshots on KVM with Virsh: And in PowerShell: Get-VM VMName | Remove-Checkpoint -Name *Well, that's for Hyper-V and isn't PowerShell. PowerShell on KVM won't work that way as those are Hyper-V local commands being called from PowerShell, and not PowerShell itself. Correct. They are PowerShell commands for Hyper-V. 
- 
 Is this a personal alias to Remove-VMSnapshot perhaps? 
- 
 @scottalanmiller said in Delete All Snapshots on KVM with Virsh: Is this a personal alias to Remove-VMSnapshot perhaps? No I had that first but edited it incorrectly. Missed the VM in front. But ya I thought vmcheckpoint was an alias but it's not. Remove-VMSnapshot is correct. So weird, they renamed it to checkpoint, but never changed the PS commands. 

