1. # Create a list of servers to process
  2. $Servers = "server1 server2 server3"
  3. $ServerList = $Servers.Split(" ")
  4.  
  5. # Now connect to virtual center
  6. Connect-VIServer -Server "vcserver"
  7. # Now revert the VM's to the "Default" snapshot
  8. foreach ($Server in $ServerList)
  9. {
  10. write-host "Processing " $Server # Retrieve snapshot properties
  11. $snap = Get-Snapshot -VM (Get-VM -Name $Server) -Name 'Default'
  12. Write-Host "Reverting snapshot from " $snap.Created
  13. # This is the action that reverting the VM to the "Default" snapshot
  14. Set-VM -VM $Server -Snapshot $snap -confirm:$false
  15. # Now update the VM's note in VC
  16. $DT = Get-Date
  17. $Message = "Restored default machine on "
  18. Set-VM -VM $Server -Description $Message $DT -confirm:$false
  19. }

 

Last Updated (Wednesday, 13 May 2009 09:10)