PoshCode Archive  Artifact Content

Artifact 57d8497f8bed8486480705088125e1fbfaf7a9e33222b4bb8816b7fd46384e00:

  • File restore-LastSnapshot.ps1 — part of check-in [306c0ee6b5] at 2018-06-10 14:09:17 on branch trunk — Revert to the last VMware snapshot with variables for Vvcenter and VM (user: TXGUY size: 832)

# encoding: ascii
# api: powershell
# title: restore-LastSnapshot
# description: Revert to the last VMware snapshot with variables for Vvcenter and VM
# version: 0.1
# author: TXGUY
# license: CC0
# x-poshcode-id: 6159
# x-archived: 2016-03-19T02:55:14
# x-published: 2016-12-31T19:13:00
#
# usage: restore-LastSnapshot -vcenter vcenter1 -vm vm1234
# Assumes powercli module has been loaded.
# You can ommit the -vcenter [vcenter] if you have already manually ran connect-viserver
#
#
#restore-LastSnapshot 
#Reverts specified VM to last (most current) snapshot
#
#


param(
	[string]$vcenter,
	[string]$vm
)


connect-viserver -server $vcenter
$snap = Get-Snapshot -VM $vm | Sort-Object -Property Created -Descending | Select -First 1
Set-VM -VM $vm -SnapShot $snap -Confirm:$false
start-vm -vm $vm