VMware Cloud Community
thepieman
Contributor
Contributor
Jump to solution

Scheduled Revert of a VM to a snapshot

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?

0 Kudos
1 Solution

Accepted Solutions
Niket
Enthusiast
Enthusiast
Jump to solution

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

View solution in original post

0 Kudos
3 Replies
LucD
Leadership
Leadership
Jump to solution

Have a look at .


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Niket
Enthusiast
Enthusiast
Jump to solution

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

0 Kudos
halr9000
Commander
Commander
Jump to solution

$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)

My signature used to be pretty, but then the forum software broked it. vExpert. Microsoft MVP (Windows PowerShell). Author, Podcaster, Speaker. I'm @halr9000