简体   繁体   中英

VMware PowerCLI - Mass Revert Snapshot

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM