this demonstration, we'll work with checkpoints in Hyper‑V.
I'm on my ARC2 Windows Server 2022 machine,
and as you can see,
I have the Hyper‑V Manager console up on the screen
and I have my server1 VM running.
This is the VM that we created in the previous module.
The first thing we need to do is ensure we have snapshots enabled,
and we can choose the default snapshot type.
We do this at the VM level.
So we'll right‑click my server1 and select Settings from the shortcut menu.
Next, we'll come down to Checkpoints,
and I do in fact have my checkpoints enabled where we can
switch between Production and Standard.
Now, of course, we can do all this programmatically.
If you wanted to set a default checkpoint for 12,
24 Hyper‑V VMs, you're going to want to use PowerShell for that.
And I'll show you that momentarily, just want to make that disclaimer.
And we can see here, Use automatic checkpoints.
This is something that you want to think about
whether you want that extra space.
There's a parent‑child relationship between the main VHD,
or virtual hard disk, and then your snapshots that basically reflect delta,
or changes, in the state of that VM.
Now I have mine set for Standard checkpoints right now.
Remember that this is going to capture the memory state,
as well as the disk state, the data state,
of the virtual machine.
Let's click OK.
And I've got a connection.
Actually, let's make an RDP connection to this machine now.
I'll make a full‑screen RDP connection to the machine.
I'll sign in, and I'm just going to create a file on the desktop,
and I'll call this workfile.txt.
And let's open it up in VS Code, and I'll just put some sample text in here.
And I'm going to save the file on my desktop.
Actually, I've already done that.
Okay.
Yeah, so we've got the file.
Great.
Let's close out of here.
And now let's minimize the virtual machine and come back to ARC2,
and I'm going to take a snapshot of the machine state.
I'm going to right‑click and go to Checkpoint.
By the way, when I use the term snapshot,
that's just my old habit mental muscle memory happening.
It's true that originally what are now called Hyper‑V
checkpoints used to be called snapshots.
Again, that's why I'm saying that.
And the exam is going to use the current terminology,
but just to let you know, snapshot, checkpoint,
they're synonymous terms.
So let me choose Checkpoint.
Now notice it creates the checkpoint, shows us the progress,
and then we can see down here in Hyper‑V Manager,
and we can right‑click and rename and apply and export.
We can do all these operations in the graphical interface.
I'll call this text file, okay?
Now what I want to do is come back to server1,
and I'm going to delete that workfile,
and I'm even going to empty the Recycle Bin to get rid of that file.
Let me close out of the RDP session.
And then we can right‑click that checkpoint and apply the checkpoint.
Are you sure you want to apply?
I can either create a new checkpoint and then apply,
which is a nice check here, pun intended,
to save the prestate and then apply.
I'm just going to go ahead and apply.
Tells us here what's happening in the status window.
Now it's going through a restoration process,
and now we're back to a running state.
So let's again make a connection.
This time I'm not going to do full screen.
I was getting a little bit confused there.
We'll sign in again,
and there we have our workfile in the spot where it
originally was created on the desktop.
And if I open up the file, we've got our sample text.
Now what I really should have done is actually showed you
that even open applications are preserved.
Let me do this.
I'll leave the app open now.
I'm going to save my work, close.
Let me make another checkpoint here.
And what I want to do now is right‑click and rename this.
I'll call this open app.
And then let me reconnect, close Notepad,
delete the file again, and let's go do the same thing.
We'll right‑click, Apply, Apply.
Another connection by double left‑clicking the server.
Sign in.
A lot of iterative work here, but you know.
There we go.
So we've got the open application.
The full RAM state of that virtual machine is preserved, okay?
If you're wondering what the snapshots look like in the file system,
what we can do is open up the work directory.
You saw in the VM settings, if we go back to Settings,
Checkpoints, we've got our checkpoint file location.
I actually have that up here.
And if we go into Snapshots,
we can get to those AVHDX files here in the work folder.
Notice that there's a number of Snapshots subfolders.
I would be careful about horsing around in the file system.
Instead, you know, we can delete, we can prune snapshots.
We can right‑click, we can export, we can delete.
We can delete an entire subtree of checkpoints.
As you notice, you see a hierarchy here.
As you've got snap, I keep saying snapshots.
As you have checkpoints based on a previous checkpoint state,
you get this hierarchical relationship here,
the subtree view.
Now to finish this part of the demo, let's show you the other type of checkpoint.
Let's go back to the VM settings, and we'll go down to Checkpoints,
and now let's go to Production checkpoints.
Now it says here,
Create standard checkpoints if the guest does not support the creation.
I'm going to untick that and click OK.
And now to set ourselves up,
let's go back and do the same thing that we did before in the VM.
I've got my workfile.txt in Notepad.
Where's the icon?
Here it is. And I'm going to add in another line, Production checkpoint. Let
me save that change, I'll keep the application open just like before, and
we'll come back and we'll make another checkpoint.
Let's right‑click Checkpoint. Hyper‑V tells us here that backup
technology in the guest operating system was used. The running
application state was not included in the checkpoint.
We can configure the checkpoint options under the VM settings. We know
that, so we don't need to see this dialog anymore. And now I'm going to
right‑click and rename this Production checkpoint.
Nice.
So you know what we're going to do now. We're going to go back into the
VM, I'm going to close and delete the workfile, going to permanently
delete it, and then we're going to come back to Hyper‑V and we're going
to apply that Production checkpoint by right‑clicking it and selecting
Apply, and then I will do Apply, and let's see what happens. Now notice
that the run state of the VM has been updated to Off, or when we apply a
production checkpoint it turns off the machine. So let me right‑click and
start it again, and let's right‑click and connect. Sign in.
Okay. The Shutdown Event Tracker senses that the machine was shut down
unexpectedly. I'm gonig to cancel out of there. And note that Notepad is not
running, pun intended, but if we open up workfile,
we still have our Production checkpoint line. So this verifies that the Volume
Shadow Copy Service picked up all of the data changes, but not the in‑memory
application state of the machine. So hopefully it's nice and clear now the
difference between those two modalities.
So let's finish by opening up VS Code where I have a file called
checkpoints.ps1. Again, I share this as I always do in the
exercise files. And here we're using the Hyper‑V PowerShell
cmdlets to do all those same operations.
So let's just review to make sure that we've locked it in here.
We've got Set‑VM CheckpointType.
So this would be a convenient way programmatically to change the
default checkpoint type between standard and production. To create a
checkpoint, we've got Checkpoint‑VM, just the name of the virtual
machine. To apply a checkpoint,
we can do two things here. Let me remove that extra line. We
can get a reference to the VM and then restore. Actually, we
might want to use a variable there.
But anyway, Restore‑VMCheckpoint, the name of the checkpoint,
the name of the VM, and then I've just got Confirm false because I don't want to
be stopped and prompted, are you sure you want to do this?
We can rename a VM checkpoint. We can export a checkpoint
to a path. Let me actually do that.
Let me go to Hyper‑V Manager, and I've got open app, so let's update this
to open‑app. And then the path c:\migrate does exist.
I created that folder. I wanted to show you what that looks like, so let's
right‑click and run that. Syntax error here, so let me put in an extra space
between the VMName parameter and the value, and let's try that again,
right‑clicking Run Selection. So if I do a directory,
once again,
syntax gets me every time. There's actually a space between
open app. So let me right‑click, Run Selection, and finally
it lights up and starts to work.
I think I mentioned in the introduction to exam AZ‑800, that's a course
that I hope you'll watch, is that AZ‑800 and AZ‑801 are very much retro
exams, they remind me almost of the old Windows Server 2008 exams, and that
means even the PowerShell is kind of retro where you won't see complicated
PowerShell like you will on the Azure exams. Like if you take the Azure
Administrator, AZ‑104,
you're going to see quite a bit of PowerShell, and if you
don't have intermediate PowerShell knowledge,
you may find yourself in deep water, all right? Here on AZ‑880 and 801,
it's much more basic PowerShell, and I'm glad to give you this
experience and practice. So let me bring up my terminal window a
bit. Let me clear the screen and do a directory listing. So we've
got our server1 folder.
Let's go in there and do a directory listing.
It's basically, let's just go to File Explorer as far as
that goes. We'll go to c:\migrate server1.
We've got one folder for virtual hard disks where we've got the VHDX,
another for virtual machines.
So it's really a nice export of the VM,
making sure that you're getting not only the VM and its configuration,
but also its snapshot.
Lastly, I have some PowerShell here for deleting a checkpoint.
You can see on line 21 Remove‑VMCheckpoint. Again,
I've got a syntax problem. And then programmatically, in
terms of saving your Hyper‑V host disk space,
you could do something like this pipeline here where we're
getting snapshots from a server, but where the creation time is
later than say 30 days ago. And then again, taking advantage of
the PowerShell pipeline, we can pipeline to remove VM snapshot.
So this might be the basis of a maintenance script to save your Hyper‑V hosts some extra space.