Scripts to revert VM's to a snapshot

  • David Hovey
  • David Hovey's Avatar Topic Author
  • Offline
  • Moderator
  • Moderator
More

For those of us who have customized pod types that are persistent and need to be reverted back to a snapshot every semester I thought it would be beneficial to share with the community my existing powerCLI script to revert to a specific snapshot.

$vms = get-vm "BASE_NAME_OF_YOUR_VM_TYPE_HERE*"
$snapname="NAME_OF_DESIRED_SNAPSHOT_TO_REVERT_TO"
foreach($vm in $vms){
    $snap = (get-snapshot -VM $vm | where {$_.name -eq $snapname})
    set-vm -vm $vm -snapshot $snap -Confirm:$false
}

If you have comments or suggestions for improvements please let me know and I will update this code as things get improved.

When I have time to transfer this script over to the VE API I will update this post containing that information in the mean time enjoy your bulk snapshot reverts.

#36

Please Log in or Create an account to join the conversation.

More

Thanks for sharing David!!

#37

Please Log in or Create an account to join the conversation.

Moderators: David HoveyShawn MonsenSuper User