1 00:00:00,840 --> 00:00:04,260 this demonstration, we'll work with checkpoints in Hyper‑V. 2 00:00:04,260 --> 00:00:07,840 I'm on my ARC2 Windows Server 2022 machine, 3 00:00:07,840 --> 00:00:08,750 and as you can see, 4 00:00:08,750 --> 00:00:11,880 I have the Hyper‑V Manager console up on the screen 5 00:00:11,880 --> 00:00:14,020 and I have my server1 VM running. 6 00:00:14,020 --> 00:00:17,440 This is the VM that we created in the previous module. 7 00:00:17,440 --> 00:00:21,140 The first thing we need to do is ensure we have snapshots enabled, 8 00:00:21,140 --> 00:00:23,500 and we can choose the default snapshot type. 9 00:00:23,500 --> 00:00:24,930 We do this at the VM level. 10 00:00:24,930 --> 00:00:29,680 So we'll right‑click my server1 and select Settings from the shortcut menu. 11 00:00:29,680 --> 00:00:31,780 Next, we'll come down to Checkpoints, 12 00:00:31,780 --> 00:00:35,080 and I do in fact have my checkpoints enabled where we can 13 00:00:35,080 --> 00:00:37,260 switch between Production and Standard. 14 00:00:37,260 --> 00:00:39,070 Now, of course, we can do all this programmatically. 15 00:00:39,070 --> 00:00:42,510 If you wanted to set a default checkpoint for 12, 16 00:00:42,510 --> 00:00:46,780 24 Hyper‑V VMs, you're going to want to use PowerShell for that. 17 00:00:46,780 --> 00:00:50,090 And I'll show you that momentarily, just want to make that disclaimer. 18 00:00:50,090 --> 00:00:53,460 And we can see here, Use automatic checkpoints. 19 00:00:53,460 --> 00:00:55,590 This is something that you want to think about 20 00:00:55,590 --> 00:00:57,380 whether you want that extra space. 21 00:00:57,380 --> 00:01:01,680 There's a parent‑child relationship between the main VHD, 22 00:01:01,680 --> 00:01:06,720 or virtual hard disk, and then your snapshots that basically reflect delta, 23 00:01:06,720 --> 00:01:09,480 or changes, in the state of that VM. 24 00:01:09,480 --> 00:01:12,760 Now I have mine set for Standard checkpoints right now. 25 00:01:12,760 --> 00:01:16,160 Remember that this is going to capture the memory state, 26 00:01:16,160 --> 00:01:19,030 as well as the disk state, the data state, 27 00:01:19,030 --> 00:01:20,210 of the virtual machine. 28 00:01:20,210 --> 00:01:21,200 Let's click OK. 29 00:01:21,200 --> 00:01:22,560 And I've got a connection. 30 00:01:22,560 --> 00:01:26,610 Actually, let's make an RDP connection to this machine now. 31 00:01:26,610 --> 00:01:30,430 I'll make a full‑screen RDP connection to the machine. 32 00:01:30,430 --> 00:01:34,140 I'll sign in, and I'm just going to create a file on the desktop, 33 00:01:34,140 --> 00:01:35,870 and I'll call this workfile.txt. 34 00:01:35,870 --> 00:01:41,450 And let's open it up in VS Code, and I'll just put some sample text in here. 35 00:01:41,450 --> 00:01:43,710 And I'm going to save the file on my desktop. 36 00:01:43,710 --> 00:01:45,890 Actually, I've already done that. 37 00:01:45,890 --> 00:01:46,510 Okay. 38 00:01:46,510 --> 00:01:48,040 Yeah, so we've got the file. 39 00:01:48,040 --> 00:01:48,250 Great. 40 00:01:48,250 --> 00:01:49,710 Let's close out of here. 41 00:01:49,710 --> 00:01:53,980 And now let's minimize the virtual machine and come back to ARC2, 42 00:01:53,980 --> 00:01:57,200 and I'm going to take a snapshot of the machine state. 43 00:01:57,200 --> 00:01:59,530 I'm going to right‑click and go to Checkpoint. 44 00:01:59,530 --> 00:02:01,750 By the way, when I use the term snapshot, 45 00:02:01,750 --> 00:02:06,260 that's just my old habit mental muscle memory happening. 46 00:02:06,260 --> 00:02:09,670 It's true that originally what are now called Hyper‑V 47 00:02:09,670 --> 00:02:11,710 checkpoints used to be called snapshots. 48 00:02:11,710 --> 00:02:13,500 Again, that's why I'm saying that. 49 00:02:13,500 --> 00:02:16,790 And the exam is going to use the current terminology, 50 00:02:16,790 --> 00:02:19,280 but just to let you know, snapshot, checkpoint, 51 00:02:19,280 --> 00:02:20,500 they're synonymous terms. 52 00:02:20,500 --> 00:02:21,670 So let me choose Checkpoint. 53 00:02:21,670 --> 00:02:25,490 Now notice it creates the checkpoint, shows us the progress, 54 00:02:25,490 --> 00:02:28,570 and then we can see down here in Hyper‑V Manager, 55 00:02:28,570 --> 00:02:32,200 and we can right‑click and rename and apply and export. 56 00:02:32,200 --> 00:02:36,000 We can do all these operations in the graphical interface. 57 00:02:36,000 --> 00:02:37,680 I'll call this text file, okay? 58 00:02:37,680 --> 00:02:40,710 Now what I want to do is come back to server1, 59 00:02:40,710 --> 00:02:42,990 and I'm going to delete that workfile, 60 00:02:42,990 --> 00:02:47,200 and I'm even going to empty the Recycle Bin to get rid of that file. 61 00:02:47,200 --> 00:02:49,230 Let me close out of the RDP session. 62 00:02:49,230 --> 00:02:53,820 And then we can right‑click that checkpoint and apply the checkpoint. 63 00:02:53,820 --> 00:02:55,540 Are you sure you want to apply? 64 00:02:55,540 --> 00:02:58,730 I can either create a new checkpoint and then apply, 65 00:02:58,730 --> 00:03:01,310 which is a nice check here, pun intended, 66 00:03:01,310 --> 00:03:04,110 to save the prestate and then apply. 67 00:03:04,110 --> 00:03:05,310 I'm just going to go ahead and apply. 68 00:03:05,310 --> 00:03:08,190 Tells us here what's happening in the status window. 69 00:03:08,190 --> 00:03:11,120 Now it's going through a restoration process, 70 00:03:11,120 --> 00:03:12,780 and now we're back to a running state. 71 00:03:12,780 --> 00:03:14,640 So let's again make a connection. 72 00:03:14,640 --> 00:03:16,800 This time I'm not going to do full screen. 73 00:03:16,800 --> 00:03:18,470 I was getting a little bit confused there. 74 00:03:18,470 --> 00:03:20,040 We'll sign in again, 75 00:03:20,040 --> 00:03:22,880 and there we have our workfile in the spot where it 76 00:03:22,880 --> 00:03:24,840 originally was created on the desktop. 77 00:03:24,840 --> 00:03:28,290 And if I open up the file, we've got our sample text. 78 00:03:28,290 --> 00:03:31,690 Now what I really should have done is actually showed you 79 00:03:31,690 --> 00:03:35,010 that even open applications are preserved. 80 00:03:35,010 --> 00:03:35,950 Let me do this. 81 00:03:35,950 --> 00:03:39,200 I'll leave the app open now. 82 00:03:39,200 --> 00:03:41,440 I'm going to save my work, close. 83 00:03:41,440 --> 00:03:43,360 Let me make another checkpoint here. 84 00:03:43,360 --> 00:03:46,550 And what I want to do now is right‑click and rename this. 85 00:03:46,550 --> 00:03:48,440 I'll call this open app. 86 00:03:48,440 --> 00:03:52,980 And then let me reconnect, close Notepad, 87 00:03:52,980 --> 00:03:56,110 delete the file again, and let's go do the same thing. 88 00:03:56,110 --> 00:03:58,290 We'll right‑click, Apply, Apply. 89 00:03:58,290 --> 00:04:01,230 Another connection by double left‑clicking the server. 90 00:04:01,230 --> 00:04:02,260 Sign in. 91 00:04:02,260 --> 00:04:04,430 A lot of iterative work here, but you know. 92 00:04:04,430 --> 00:04:05,220 There we go. 93 00:04:05,220 --> 00:04:07,130 So we've got the open application. 94 00:04:07,130 --> 00:04:11,000 The full RAM state of that virtual machine is preserved, okay? 95 00:04:11,000 --> 00:04:14,000 If you're wondering what the snapshots look like in the file system, 96 00:04:14,000 --> 00:04:17,070 what we can do is open up the work directory. 97 00:04:17,070 --> 00:04:20,480 You saw in the VM settings, if we go back to Settings, 98 00:04:20,480 --> 00:04:23,800 Checkpoints, we've got our checkpoint file location. 99 00:04:23,800 --> 00:04:25,150 I actually have that up here. 100 00:04:25,150 --> 00:04:27,540 And if we go into Snapshots, 101 00:04:27,540 --> 00:04:31,560 we can get to those AVHDX files here in the work folder. 102 00:04:31,560 --> 00:04:34,970 Notice that there's a number of Snapshots subfolders. 103 00:04:34,970 --> 00:04:37,910 I would be careful about horsing around in the file system. 104 00:04:37,910 --> 00:04:41,310 Instead, you know, we can delete, we can prune snapshots. 105 00:04:41,310 --> 00:04:44,490 We can right‑click, we can export, we can delete. 106 00:04:44,490 --> 00:04:48,100 We can delete an entire subtree of checkpoints. 107 00:04:48,100 --> 00:04:50,590 As you notice, you see a hierarchy here. 108 00:04:50,590 --> 00:04:53,000 As you've got snap, I keep saying snapshots. 109 00:04:53,000 --> 00:04:57,560 As you have checkpoints based on a previous checkpoint state, 110 00:04:57,560 --> 00:05:00,120 you get this hierarchical relationship here, 111 00:05:00,120 --> 00:05:01,550 the subtree view. 112 00:05:01,550 --> 00:05:06,400 Now to finish this part of the demo, let's show you the other type of checkpoint. 113 00:05:06,400 --> 00:05:10,520 Let's go back to the VM settings, and we'll go down to Checkpoints, 114 00:05:10,520 --> 00:05:12,580 and now let's go to Production checkpoints. 115 00:05:12,580 --> 00:05:13,940 Now it says here, 116 00:05:13,940 --> 00:05:18,020 Create standard checkpoints if the guest does not support the creation. 117 00:05:18,020 --> 00:05:20,140 I'm going to untick that and click OK. 118 00:05:20,140 --> 00:05:21,550 And now to set ourselves up, 119 00:05:21,550 --> 00:05:25,290 let's go back and do the same thing that we did before in the VM. 120 00:05:25,290 --> 00:05:27,950 I've got my workfile.txt in Notepad. 121 00:05:27,950 --> 00:05:28,980 Where's the icon? 122 00:05:28,980 --> 00:05:34,080 Here it is. And I'm going to add in another line, Production checkpoint. Let 123 00:05:34,080 --> 00:05:38,840 me save that change, I'll keep the application open just like before, and 124 00:05:38,840 --> 00:05:41,540 we'll come back and we'll make another checkpoint. 125 00:05:41,540 --> 00:05:45,440 Let's right‑click Checkpoint. Hyper‑V tells us here that backup 126 00:05:45,440 --> 00:05:49,210 technology in the guest operating system was used. The running 127 00:05:49,210 --> 00:05:52,370 application state was not included in the checkpoint. 128 00:05:52,370 --> 00:05:56,220 We can configure the checkpoint options under the VM settings. We know 129 00:05:56,220 --> 00:05:59,590 that, so we don't need to see this dialog anymore. And now I'm going to 130 00:05:59,590 --> 00:06:03,920 right‑click and rename this Production checkpoint. 131 00:06:03,920 --> 00:06:04,460 Nice. 132 00:06:04,460 --> 00:06:07,300 So you know what we're going to do now. We're going to go back into the 133 00:06:07,300 --> 00:06:11,890 VM, I'm going to close and delete the workfile, going to permanently 134 00:06:11,890 --> 00:06:15,420 delete it, and then we're going to come back to Hyper‑V and we're going 135 00:06:15,420 --> 00:06:19,820 to apply that Production checkpoint by right‑clicking it and selecting 136 00:06:19,820 --> 00:06:24,090 Apply, and then I will do Apply, and let's see what happens. Now notice 137 00:06:24,090 --> 00:06:28,920 that the run state of the VM has been updated to Off, or when we apply a 138 00:06:28,920 --> 00:06:32,790 production checkpoint it turns off the machine. So let me right‑click and 139 00:06:32,790 --> 00:06:36,190 start it again, and let's right‑click and connect. Sign in. 140 00:06:36,190 --> 00:06:40,500 Okay. The Shutdown Event Tracker senses that the machine was shut down 141 00:06:40,500 --> 00:06:44,810 unexpectedly. I'm gonig to cancel out of there. And note that Notepad is not 142 00:06:44,810 --> 00:06:47,700 running, pun intended, but if we open up workfile, 143 00:06:47,700 --> 00:06:51,830 we still have our Production checkpoint line. So this verifies that the Volume 144 00:06:51,830 --> 00:06:57,180 Shadow Copy Service picked up all of the data changes, but not the in‑memory 145 00:06:57,180 --> 00:07:01,180 application state of the machine. So hopefully it's nice and clear now the 146 00:07:01,180 --> 00:07:03,430 difference between those two modalities. 147 00:07:03,430 --> 00:07:07,710 So let's finish by opening up VS Code where I have a file called 148 00:07:07,710 --> 00:07:11,510 checkpoints.ps1. Again, I share this as I always do in the 149 00:07:11,510 --> 00:07:15,160 exercise files. And here we're using the Hyper‑V PowerShell 150 00:07:15,160 --> 00:07:18,030 cmdlets to do all those same operations. 151 00:07:18,030 --> 00:07:21,390 So let's just review to make sure that we've locked it in here. 152 00:07:21,390 --> 00:07:23,720 We've got Set‑VM CheckpointType. 153 00:07:23,720 --> 00:07:27,160 So this would be a convenient way programmatically to change the 154 00:07:27,160 --> 00:07:31,060 default checkpoint type between standard and production. To create a 155 00:07:31,060 --> 00:07:34,680 checkpoint, we've got Checkpoint‑VM, just the name of the virtual 156 00:07:34,680 --> 00:07:36,570 machine. To apply a checkpoint, 157 00:07:36,570 --> 00:07:40,080 we can do two things here. Let me remove that extra line. We 158 00:07:40,080 --> 00:07:43,210 can get a reference to the VM and then restore. Actually, we 159 00:07:43,210 --> 00:07:44,700 might want to use a variable there. 160 00:07:44,700 --> 00:07:48,460 But anyway, Restore‑VMCheckpoint, the name of the checkpoint, 161 00:07:48,460 --> 00:07:52,790 the name of the VM, and then I've just got Confirm false because I don't want to 162 00:07:52,790 --> 00:07:55,960 be stopped and prompted, are you sure you want to do this? 163 00:07:55,960 --> 00:08:00,010 We can rename a VM checkpoint. We can export a checkpoint 164 00:08:00,010 --> 00:08:02,300 to a path. Let me actually do that. 165 00:08:02,300 --> 00:08:06,940 Let me go to Hyper‑V Manager, and I've got open app, so let's update this 166 00:08:06,940 --> 00:08:10,960 to open‑app. And then the path c:\migrate does exist. 167 00:08:10,960 --> 00:08:14,540 I created that folder. I wanted to show you what that looks like, so let's 168 00:08:14,540 --> 00:08:19,490 right‑click and run that. Syntax error here, so let me put in an extra space 169 00:08:19,490 --> 00:08:23,530 between the VMName parameter and the value, and let's try that again, 170 00:08:23,530 --> 00:08:27,440 right‑clicking Run Selection. So if I do a directory, 171 00:08:27,440 --> 00:08:28,170 once again, 172 00:08:28,170 --> 00:08:32,210 syntax gets me every time. There's actually a space between 173 00:08:32,210 --> 00:08:36,550 open app. So let me right‑click, Run Selection, and finally 174 00:08:36,550 --> 00:08:38,380 it lights up and starts to work. 175 00:08:38,380 --> 00:08:43,090 I think I mentioned in the introduction to exam AZ‑800, that's a course 176 00:08:43,090 --> 00:08:47,880 that I hope you'll watch, is that AZ‑800 and AZ‑801 are very much retro 177 00:08:47,880 --> 00:08:52,490 exams, they remind me almost of the old Windows Server 2008 exams, and that 178 00:08:52,490 --> 00:08:56,630 means even the PowerShell is kind of retro where you won't see complicated 179 00:08:56,630 --> 00:09:00,550 PowerShell like you will on the Azure exams. Like if you take the Azure 180 00:09:00,550 --> 00:09:02,640 Administrator, AZ‑104, 181 00:09:02,640 --> 00:09:05,020 you're going to see quite a bit of PowerShell, and if you 182 00:09:05,020 --> 00:09:07,110 don't have intermediate PowerShell knowledge, 183 00:09:07,110 --> 00:09:12,120 you may find yourself in deep water, all right? Here on AZ‑880 and 801, 184 00:09:12,120 --> 00:09:15,400 it's much more basic PowerShell, and I'm glad to give you this 185 00:09:15,400 --> 00:09:19,230 experience and practice. So let me bring up my terminal window a 186 00:09:19,230 --> 00:09:22,670 bit. Let me clear the screen and do a directory listing. So we've 187 00:09:22,670 --> 00:09:24,540 got our server1 folder. 188 00:09:24,540 --> 00:09:26,700 Let's go in there and do a directory listing. 189 00:09:26,700 --> 00:09:29,450 It's basically, let's just go to File Explorer as far as 190 00:09:29,450 --> 00:09:33,030 that goes. We'll go to c:\migrate server1. 191 00:09:33,030 --> 00:09:37,640 We've got one folder for virtual hard disks where we've got the VHDX, 192 00:09:37,640 --> 00:09:39,590 another for virtual machines. 193 00:09:39,590 --> 00:09:43,070 So it's really a nice export of the VM, 194 00:09:43,070 --> 00:09:46,840 making sure that you're getting not only the VM and its configuration, 195 00:09:46,840 --> 00:09:48,300 but also its snapshot. 196 00:09:48,300 --> 00:09:51,730 Lastly, I have some PowerShell here for deleting a checkpoint. 197 00:09:51,730 --> 00:09:55,550 You can see on line 21 Remove‑VMCheckpoint. Again, 198 00:09:55,550 --> 00:09:58,660 I've got a syntax problem. And then programmatically, in 199 00:09:58,660 --> 00:10:02,050 terms of saving your Hyper‑V host disk space, 200 00:10:02,050 --> 00:10:04,820 you could do something like this pipeline here where we're 201 00:10:04,820 --> 00:10:09,330 getting snapshots from a server, but where the creation time is 202 00:10:09,330 --> 00:10:13,570 later than say 30 days ago. And then again, taking advantage of 203 00:10:13,570 --> 00:10:17,410 the PowerShell pipeline, we can pipeline to remove VM snapshot. 204 00:10:17,410 --> 00:10:25,000 So this might be the basis of a maintenance script to save your Hyper‑V hosts some extra space.