← script library
Efficient Virtual Machine Snapshot Management with PowerShell and Hyper-V
Hyper-VJanuary 10, 2025
In this post, we will explore a useful PowerShell script that helps manage Hyper-V virtual machine snapshots efficiently. This script allows you to create a snapshot of a specified virtual machine and provide feedback on the operation's status. This is particularly beneficial for system administrators who need to manage multiple VMs and ensure they have up-to-date backups.
powershell
$vmName = "YourVMName" # Replace with your VM name
if (-not (Get-VM -Name $vmName -ErrorAction SilentlyContinue)) {
Write-Host "The virtual machine '$vmName' does not exist."
return
}
$snapshotName = "$vmName-Snapshot-$(Get-Date -Format 'yyyyMMdd-HHmmss')"
try {
Checkpoint-VM -Name $vmName -SnapshotName $snapshotName
Write-Host "Snapshot '$snapshotName' created successfully for '$vmName'."
} catch {
Write-Host "ERROR: ""$($_.Exception.Message)"""
}
$snapshots = Get-VM -Name $vmName | Get-VMSnapshot
if ($snapshots) {
Write-Host "Current snapshots for '$vmName':"
$snapshots | Format-Table -Property Name, CreationTime
} else {
Write-Host "No snapshots found for '$vmName'."
}Run 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 Hyper-V
Create a Hyper-V Checkpoint with PowerShell
2026-08-17Delete Old Hyper-V Checkpoints with PowerShell
2026-08-17Start a Hyper-V VM with PowerShell
2026-08-17Shut Down a Hyper-V VM with PowerShell
2026-08-17Efficient Hyper-V VM Status Reporting Script
2025-01-10Hyper-V Virtual Machine Snapshot Management Script
2025-01-10Ready when you are.
Try ServerEngine free for 7 days.