Takes a quiesced snapshot of every VM in a list, with a description carrying the timestamp of the run, and reports per VM whether the snapshot was created, failed or whether the VM was not found at all. Memory state is off by default, which keeps the snapshots small and fast; quiescing is on, which is what makes them consistent.
powershell
$server = "esxi.example.local"
$snapshotName = "PrePatch-Snapshot"
$snapshotDescription = "Snapshot before patch window - $(Get-Date -Format 'yyyy-MM-dd HH:mm')"
$includeMemory = $false
$quiesce = $true
$vmNames = @(
"VM01",
"VM02",
"VM03",
"VM04"
)
Set-PowerCLIConfiguration -Scope User -ParticipateInCEIP $true -Confirm:$false
$username = "SE-CredentialsStore.Username.(esxi.example.local)"
$password = "SE-CredentialsStore.Password.(esxi.example.local)"
$securePassword = ConvertTo-SecureString $password -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($username, $securePassword)
Connect-VIServer -Server $server -Credential $credential
Write-Host "<WRITE-LOG = ""*================== Create Bulk Snapshots ==================*"">"
foreach ($vmName in $vmNames) {
$vm = Get-VM -Name $vmName -ErrorAction SilentlyContinue
if ($vm) {
try {
New-Snapshot -VM $vm -Name $snapshotName -Description $snapshotDescription -Memory:$includeMemory -Quiesce:$quiesce -Confirm:$false
Write-Host "<WRITE-LOG = ""*SUCCESS: Snapshot '$snapshotName' created on VM: $vmName*"">"
} catch {
Write-Host "<WRITE-LOG = ""*ERROR: Failed to create snapshot on VM: $vmName - $($_.Exception.Message)*"">"
}
} else {
Write-Host "<WRITE-LOG = ""*WARNING: VM not found: $vmName*"">"
}
}
Disconnect-VIServer -Server $server -Confirm:$falseRun it across your fleet
This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.
More in VMware & vSphere
Ready when you are.
Try ServerEngine free for 7 days.