In this blog post we are going to have a look at how you can create, manage, apply, and remove VM Checkpoints in Hyper-V using PowerShell. Hyper-V virtual machine (VM) checkpoints are one of the great benefits of virtualization. Before Windows Server 2012 R2, they were known as virtual machine snapshots. VM Checkpoints in Hyper-V allow you to save the system state of a VM to a specific time and then revert back to that state if you need to. This is great if you are testing software and configuration changes, or if you have a demo environment, which you want to reset.
Hyper-V VM Checkpoint Types
Before we got on how you can manage Hyper-V VM Checkpoints with PowerShell, let me first explain the two different types. Since Windows Server 2016 and Windows 10, Hyper-V includes two types of checkpoints, Standard Checkpoints, and Production Checkpoints.
- Standard Checkpoints: takes a snapshot of the virtual machine and virtual machine memory state at the time the checkpoint is initiated. A snapshot is not a full backup and can cause data consistency issues with systems that replicate data between different nodes such as Active Directory. Hyper-V only offered standard checkpoints (formerly called snapshots) prior to Windows 10.
- Production Checkpoints: uses Volume Shadow Copy Service or File System Freeze on a Linux virtual machine to create a data-consistent backup of the virtual machine. No snapshot of the virtual machine memory state is taken.
You can set up these settings in Hyper-V Manager or in PowerShell.
If you are using PowerShell to configure Checkpoints for virtual machines these commands may help you.
Configure and set VM for Standard Checkpoints
Set-VM -Name "Windows10" -CheckpointType Standard
Set VM to Production Checkpoints, if the production checkpoint fails a Standard Checkpoint is created
Set-VM -Name "Windows10" -CheckpointType Production
Set VM to only use Production Checkpoints
Set-VM -Name "Windows10" -CheckpointType ProductionOnly
Disable VM Checkpoints for the Hyper-V virtual machine
Set-VM -Name "Windows10" -CheckpointType Disabled
Managing Hyper-V VM Checkpoints using PowerShell
Create VM Checkpoints
You can create a new VM Checkpoint with PowerShell, you can round the following command:
Checkpoint-VM -Name "Windows10"
You can find more on the cmdlet on Microsoft Docs.
You can list the VM Checkpoints of a Hyper-V VM:
Get-VMCheckpoint -VMName "Windows10"
Applying Hyper-V VM checkpoints using PowerShell
If you want to revert your virtual machine state to a previous point-in-time, you can apply an existing checkpoint, using the following PowerShell command.
Restore-VMCheckpoint -Name "checkpoint name" -VMName "Windows10" -Confirm:$false
You can find more information about the cmdlet here.
Renaming checkpoints
To rename a checkpoint you can use the following command
Rename-VMCheckpoint -VMName "Windows10" -Name "Checkpointname" -NewName "MyNewCheckpointName"
Deleting checkpoints
You can also delete or remove a Hyper-V VM checkpoint with the following PowerShell command. This will merge the .avhdx files in the background.
Remove-VMCheckpoint -VMName "Windows10" -Name "Checkpointname"
Conclusion
I hope this blog post gives you a great overview on how you can manage, apply, restore, and remove Hyper-V VM Checkpoints using PowerShell. You can learn more about Hyper-V virtual machine checkpoints on Microsoft Docs. If you have any questions, feel free to leave a comment.
Tags: Apply, Checkpoint, create, Delete, Hyper-V, Hyper-V Checkpoint, Manage, Microsoft, PowerShell, Remove, Snapshot, Virtual, Virtual Machine, Virtualization, VM, VM Checkpoint, Windows 10, Windows Server Last modified: July 7, 2020
[…] How To Manage Hyper-V VM Checkpoints With Powershell […]
very nice!
thank you for colaborate!
The command seems to be get-vmsnapshot rather than get-vmcheckpoint. Did something change at some point?
On which operating system are you running the commands? (Which version)