2014-06-18 129 views
1

我试图将一个虚拟机的阵列(从C:\ esx \ vmlist.txt创建)恢复为快照“测试”(所有快照都与名为“测试”的快照同时进行“)。VMware PowerCLI - 大量还原快照

这里是我的脚本:

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 

有什么想法?

回答

2

要恢复的快照,你可以使用Set-VM的cmdlet:

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

以防万一:你可能要与-WhatIf(而不是-Confirm:$false)首先运行此。

+0

非常感谢!我不得不删除第一个-Confirm:$ false,因为它不会运行。 – l0sts0ck

+0

这部分实际上是从您的代码中复制/粘贴的,现在根据建议删除/更新。很高兴我能帮上忙。 :) – BartekB