Created
March 31, 2018 07:07
-
-
Save joe-speedboat/7538134740d8e72346007026db7cd8b1 to your computer and use it in GitHub Desktop.
remove all snapshots of all vms on esxi
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
removeAllSnapshots(){ | |
vim-cmd vmsvc/getallvms | grep -v Vmid | awk '{print $1":"$2}' | grep '^[0-9]' | while read VM | |
do | |
VMID=$(echo $VM | cut -d: -f1) | |
vmName=$(echo $VM | cut -d: -f2) | |
echo "INFO: `date '+%Y.%m.%d_%H:%M'`: search Snapshots of VM: $vmName ---" | |
vim-cmd vmsvc/get.snapshot $VMID | grep -A5 'snapshot = ' | sed '/id =/!d;s/.*id = //g;s/,//g' | while read SNAPID | |
do | |
echo exec: vim-cmd vmsvc/snapshot.remove $VMID $SNAPID | |
vim-cmd vmsvc/snapshot.remove $VMID $SNAPID | |
done | |
done | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment