我正在尝试将VM的数组(从C:\ esx \ vmlist.txt创建)恢复为快照“test”(所有快照均为快照,同时快照名为“test”)。

这是我的脚本:

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

有什么想法吗?

最佳答案

要还原快照,可以使用Set-VM cmdlet:

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

以防万一:您可能首先要使用-WhatIf(而不是-Confirm:$false)运行它。

关于powershell - VMware PowerCLI-批量还原快照,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24294446/

10-12 00:18
查看更多