Q
Manage Learn to apply best practices and optimize your operations.

Use PowerShell when working with Hyper-V checkpoints

With just a PowerShell cmdlet or two, you can create Hyper-V checkpoints, get a list of all existing checkpoints for a VM or revert a VM to a specific checkpoint.

Hyper-V checkpoints can help an administrator roll back changes in the event of a problem by taking point-in-time...

images of Hyper-V VM. For example, you can take checkpoints of a VM, perform your application testing and revert the checkpoint to a known state if you need to retest. Although you can use Hyper-V Manager to perform checkpoint tasks, it's easier to do the same tasks using PowerShell.

By default, Hyper-V checkpoints aren't enabled on VMs. In order to execute the PowerShell commands below, you'll be required to enable checkpoints on the VMs. You can use the Hyper-V Manager to enable checkpoints for a VM, but you can also execute the Set-VM PowerShell cmdlet. To enable checkpoints for a single VM, execute the Set-VM –Name SQLVM –CheckPointType Enable PowerShell command. Next, run Set-VM –Name SQLVM –CheckPointType ProductionOnly to configure the VM to use a production checkpoint -- first introduced in Hyper-V 2016.

Once you have enabled checkpoints for a VM, you can execute the below PowerShell commands to take checkpoints or revert to a checkpoint of your choice.

Create a checkpoint

To create a checkpoint, use the CheckPoint-VM PowerShell cmdlet. Just executing CheckPoint-VM –Name SQLVM will create a checkpoint for an SQLVM. If you need to take another checkpoint, execute the same command. Note that when you take a checkpoint, Hyper-V creates a checkpoint entry with the date and time when the checkpoint was taken.

To list all of the Hyper-V checkpoints for a VM, use Get-VMSnapshot –VMName SQLVM.

Note that the Checkpoint-VM PowerShell cmdlet doesn't support taking checkpoints for a VM running on a remote Hyper-V host. If you need to perform a checkpoint for a remote VM, interact with the remote VM using the Get-VM PowerShell cmdlet and then pipe the Checkpoint-VM cmdlet as shown in the command below:

Get-VM Remote_SQLVM –ComuterName RemoteHyper-VHost | Checkpoint-VM

By using the command above, you are performing a checkpoint for a VM that is running on RemoteHyper-VHost.

To restore or revert to a checkpoint for a VM, use the Restore-VMSnapshot PowerShell cmdlet. If you would like to restore an SQLVM to a previous checkpoint, execute the PowerShell commands below:

$ThisVM = “SQLVM”

$ThisVM | Get-VM | Get-VMSnapshot –Name “SnapshotName” | Restore-VMSnapshot –Confirm:$False

Note that you will be required to stop the VM before performing the checkpoint restore operation.

Next Steps

Learn about the different Hyper-V checkpoints

Navigate the new features in Hyper-V 2016

Perform a Hyper-V health check with PowerShell

Dig Deeper on Microsoft Hyper-V management

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Join the conversation

1 comment

Send me notifications when other members comment.

Please create a username to comment.

What are some other uses of Hyper-V checkpoints?
Cancel

-ADS BY GOOGLE

SearchVMware

SearchWindowsServer

SearchCloudComputing

SearchVirtualDesktop

SearchDataCenter

Close