2

I'm trying to revert an array of VM's (created from C:\esx\vmlist.txt) to snapshot "test" (all were snapshot at the same time with a snapshot named "test").

Here's my script:

Add-PSSnapin VMware.VimAutomation.Core

Connect-VIServer -Server 192.168.10.10 -User root -Password mypass

$VMs = Get-Content'C:\esx\vmlist.txt'

$snapname = Read-Host 'Snapshot Name:'

Get-Snapshot -VM $VMs -Name $snapname -confirm:$false

Any thoughts?

l0sts0ck
  • 373
  • 1
  • 4
  • 10

1 Answers1

3

To revert snapshot, you would use Set-VM cmdlet:

Get-Snapshot -VM $VMs -Name $snapname | Foreach-Object {
    Set-VM -VM $_.VM -Snapshot $_ -Confirm:$false
}

Just in case: you may want to run this with -WhatIf (instead of -Confirm:$false) first.

BartekB
  • 8,492
  • 32
  • 33