Automation

 View Only
  • 1.  Scheduled Revert of a VM to a snapshot

    Posted Jun 19, 2008 01:45 PM

    I'm new to Powershell and need to script a Virtual Machine to revert to a Snapshot on a weekly basis

    The Snapshot name and VM name will always be know

    I presume I can scedule via Windows Task Scheduler?



  • 2.  RE: Scheduled Revert of a VM to a snapshot

    Posted Jun 19, 2008 01:52 PM

    Have a look at .



  • 3.  RE: Scheduled Revert of a VM to a snapshot
    Best Answer

    Posted Jun 19, 2008 02:41 PM

    Hi,

    Below script can be used to revert to a Snapshot.

    $server = get-viserver -server ) -Confirm:$false

    This script can be scheduled to run on weekly basis by scheduler.

    Thanks

    Niket



  • 4.  RE: Scheduled Revert of a VM to a snapshot

    Posted Jun 19, 2008 02:56 PM

    $server = get-viserver -server <server> -user <user> -password <pwd>

    Set-VM -Snapshot (Get-Snapshot -Name <Snp Name> -VM (Get-VM -Name <VM Name>)) -VM (Get-VM -Name <VM Name>) -Confirm:$false

    Variant on the above to get you used to the pipeline:

    $vmname = "foo"

    $snapname = "weekly revert snapshot"

    $vm = get-vm $vmname

    $vm | set-vm -snapshot ( $vm | get-snapshot $snapname ) -confirm:$false

    Hal Rottenberg

    Co-Host, PowerScripting Podcast (http://powerscripting.net)