Revert to snapshot from within a VM
For a couple of ThinApp packaging machines I didn’t want that the packagers had access to the vCenter Client, but still let them revert to a previous snapshot.
So I wrote a couple of lines to accomplish just that from within the packaging machine itself.
The script below reverts the virtual machine back to the snapshot that was created earlier.
$snap=Get-Snapshot -vm (get-vm -name $vmname) -name $snapname
set-vm -vm (get-vm -name $vmname) -Snapshot $snap -confirm:$false
Prequisites for this are that PowerShell is installed on the machine as is the PowerCLI. You also need a user account that has just enough permissions in vCenter to connect, do some VM actions like reboot and revert to snapshot.
Anne Jan Elsinga
Anne Jan Elsinga is a Technical Account Manager for VMware. In the past he worked as presales and technical consultancy and architecture for several systems integrators. From 2009 until 2017 he was awarded with the VMware vExpert status. In the night time he dances latin, ballroom and salsa and he also discovered the pleasure of diving and woodworking. Recently he started blogging about smart homes and comfort in general.