Using PowerShell to Manage Hyper-V Checkpoints

Share

In this article, you’ll find out how you can use PowerShell with Hyper-V checkpoints to make managing your virtualised infrastructure much more efficient.

Checkpoints allow you to capture the status of a virtual machine (VM) at a given point in time and then revert to that status later if necessary.

This is particularly useful if you want to revert to how things were before you installed a new program or tried out some changes to your configuration.

NOTE: A snapshot is not a backup and can cause problems, particularly with regard to data consistency when copying data with AD DS or other systems.

 

Using PowerShell to Manage Hyper-V Checkpoints

 

Changing the Type of Checkpoint

There are three different types of checkpoints available in Hyper-V: Standard, Production and ProductionOnly.

  • Standard: This takes a snapshot of the VM and the RAM at a given moment.
  • Production: Using the Volume Shadow Copy Service, it creates a data-consistent backup of the VM. It does not capture the RAM. If it fails for some reason, a Standard Checkpoint will be created.
  • ProductionOnly: As above but, in the event of a failure, it will not create a Standard Checkpoint instead.

To configure them, you need to use the “Set-VM” command with the name of the VM and the type of checkpoint as command parameters. Here are a few examples:

# Set-VM -Name <VM_Name> -CheckpointType Standard

# Set-VM -Name <VM_Name> -CheckpointType Production

# Set-VM -Name <VM_Name> -CheckpointType ProductionOnly

And now, with the VM name included:

# Set-VM -Name WS2016 -CheckpointType Standard

# Set-VM -Name WS2016 -CheckpointType Production

# Set-VM -Name WS2016 -CheckpointType ProductionOnly

Image - Configuring different types of checkpoint in Hyper-V using PowerShell
Image – Configuring different types of checkpoint in Hyper-V using PowerShell

 

Creating Hyper-V Checkpoints Using PowerShell

Next, we’ll look at how to create a checkpoint. There are actually multiple ways to do this, but we’ll focus on just a couple of them.

On the one hand, you can create a checkpoint whereby you only enter the name of the VM and the system will do the rest:

# Checkpoint-VM -Name <VM_Name>

For example:

# Checkpoint-VM -Name WS2016

On the other hand, you can create a checkpoint and specify the type:

# Checkpoint-VM -Name <VM_Name> -CheckpointType <Type>

So, in this case, you’ll have to enter the name of the VM and the CheckpointType, which obviously will need to be either “Standard”, “Production” or “ProductionOnly”.

Here’s an example:

# Checkpoint-VM -Name WS2016 -CheckpointType Standard

Personally, I also recommend checking that the checkpoint has been created successfully. You can do this by using the “Get-VMCheckpoint” command to list the checkpoints that have been created. For example:

# Get-VMCheckpoint -Name WS2016

Image - Creating a Hyper-V checkpoint with PowerShell
Image – Creating a Hyper-V checkpoint with PowerShell

 

Renaming a Checkpoint

You can also use PowerShell to change the name of any previously created checkpoint. This can be really useful because when a checkpoint is first created, it is given a name based on the time it was generated, and it’s not very convenient. It’s much easier to keep track of your checkpoints if they’re named something a little more descriptive, indicating that it was made before installing a new program, running a test, etc.

To rename a checkpoint, you can use the “Rename-VMCheckpoint” command as follows:

# Rename-VMCheckpoint -VMName <Name> -Name <Checkpoint_Name> -NewName <New_Checkpoint_Name>

Where:

  • <Name>: is the name of the VM.
  • <Checkpoint_Name>: is the name of the checkpoint you want to change.
  • <Nuevo_Nombre_Punto_Control>: is the new name for the checkpoint.

So, for example, this might look something like this:

# Rename-VMCheckpoint -VMName W10ENTest01 -Name ‘W10ENTest01 – (25/05/2023 – 12:02:00)’ -NewName ‘W10ENTest01 – Tests’

Again, once you run this command, it’s a good idea to check that it has been done successfully by using the following command:

# Getc-VMCheckpoint -VMName <Name>

Image - Renaming a checkpoint using PowerShell
Image – Renaming a checkpoint using PowerShell

 

Restoring a Hyper-V Checkpoint Using PowerShell

Restoring a checkpoint allows you to revert the VM to how it was before you applied a change.

To this, you need to get a list of checkpoints for the VM in question using the following command:

# Get-VMCheckpoint -VMName <Name>

Where “<Name>” is the name of the VM.

For us, this would look something like this:

# Get-VMCheckpoint -VMName WS2016

Next, once you’ve chosen which checkpoint you want to restore, run the “Restore-VMCheckpoint” command, using the following format:

# Restore-VMCheckpoint -Name <Checkpoint_Name> -VMName <Name> -Confirm:$false

Where:

  • <Name>: is the name of the VM.
  • <Checkpoint_Name>: is the name of the checkpoint you want to restore.

So, for our example, the full command would be as follows:

# Restore-VMCheckpoint -Name ‘WS2016 – Test Point’ -VMName WS2016 -Confirm:$false

Image - Restoring a Hyper-V checkpoint using PowerShell
Image – Restoring a Hyper-V checkpoint using PowerShell

 

Exporting Hyper-V Checkpoints

When you export a checkpoint, what you’re actually doing is creating a folder structure where all the necessary packages are added so you can move the VM to another server and deploy it there.

To deploy the VM on the new server, all you need to do is import the VM and restore the checkpoint.

This could be used as a kind of backup for extreme scenarios where you need a Disaster Recovery mechanism.

To export the VM, we recommend first listing the available checkpoints and then using the “Export-VMCheckpoint” command with the following syntax:

# Export-VMCheckpoint -VMName <Name> -Name <Checkpoint_Name> -Path <Export_Path>

Where:

  • <Name>: is the name of the VM.
  • <Checkpoint_Name>: is the name of the checkpoint.
  • <Export_Path>: is the folder the VM will be exported to.

So, for example, the whole command would look something like this:

# Export-VMCheckpoint -VMName W10ENTest01 -Name ‘W10ENTest01 – Tests’ -Path ‘C:\Data’

Image - Exporting a Hyper-V checkpoint using PowerShell
Image – Exporting a Hyper-V checkpoint using PowerShell

It’s very important to remember that the exported files will be the same size as the VM. So, use this command with care!

 

Removing Hyper-V Checkpoints

When you no longer need a checkpoint, it’s good practice to delete it so your old checkpoints don’t clutter up your system, especially since they can overload your server and drastically reduce performance.

To remove a checkpoint, first, get a list of available checkpoints for the VM in question:

# Get-VMCheckpoint -VMName <Name>

Where “<Name>” is the name of the VM.

Then, from this list, select the checkpoint that you want to delete and run the following command:

# Remove-VMCheckpoint -VMName <Name> -Name <Checkpoint_Name>

Where “<Name>” is the name of the VM and “<Checkpoint_Name>” is the checkpoint you want to remove.

Here’s an example:

# Remove-VMCheckpoint -VMName W10ENTest01 -Name ‘W10ENTest01 – Tests’

Lastly, you should check that the checkpoint has been removed by running the “Get-VMCheckpoint” command once again.

Image - Removing a Hyper-V checkpoint
Image – Removing a Hyper-V checkpoint

You now know the PowerShell commands to do more or less anything you might need to do with Hyper-V checkpoints!

 

Summary

As you can see, using PowerShell to manage your Hyper-V checkpoints will make things much easier and quicker for you when managing your virtualised infrastructure. Although the graphic interface is easy to use, PowerShell is infinitely quicker. So, it’s always worth learning how to use it.

If you’re interested in learning more about this topic and would like to try some things out on your desktop, check out our tutorial How to Install Hyper-V on Windows 10. You can also read our article titled PowerShell Commands for Hyper-V to learn other useful commands.

And that’s not all. In reality, we’ve got plenty of other tutorials and articles related to Hyper-V that you’re free to browse on our website.

Thanks for reading!

Category:Cloud and Systems

Other posts that may interest you

9 de August de 2024
Choosing the right cloud service provider is a critical decision that can impact the quality of your software, customer
3 de July de 2024
Here at Jotelulu, we have designed our Disaster Recovery service specifically with SMEs in mind. But what arguments should
2 de July de 2024
In today’s article, we will explain some of the basic concepts that are important to understand about Jotelulu’s Disaster

Fill out the form and one of our Sales team will contact you soon.

growth@jotelulu.com  |  jotelulu.com 

You can unsubscribe from these communications at any time. For more information,  check our Privacy Policy.

 

We make the difficult easy

Existing Disaster Recovery tools often require advanced knowledge to manage, demanding expertise that is difficult to acquire.

Jotelulu’s Disaster Recovery aims to make the difficult easy and offers a very simple deployment based on a three-step configuration:

Origin (Primary Site)
Determine the origin location of the subscription on which the Disaster Recovery service will be established.

Destination (Recovery Site)
Set the destination location (availability zone) where you want the Recovery Site to be deployed.

Replication characteristics
Specify the data related to the number of copies to be kept and the frequency at which the replication will be performed.