1 00:00:01,840 --> 00:00:05,610 We're going to pick up on this demo where we left off on the previous one. 2 00:00:05,610 --> 00:00:10,180 To set the stage for you again, I'm on my host here, ARC2, 3 00:00:10,180 --> 00:00:14,900 and I just completed installing a virtual machine called server1, 4 00:00:14,900 --> 00:00:18,090 this is what you're looking at in the internal machine, and I now 5 00:00:18,090 --> 00:00:22,540 want to demonstrate PowerShell Direct versus PowerShell remoting 6 00:00:22,540 --> 00:00:25,210 from the Hyper‑V host to the guest. 7 00:00:25,210 --> 00:00:27,840 So what I'm going to do is bring up my VS Code, and as 8 00:00:27,840 --> 00:00:29,580 you can see in my terminal output, 9 00:00:29,580 --> 00:00:34,280 I ran hostname to verify that I am on ARC2. First of all, to 10 00:00:34,280 --> 00:00:37,990 demonstrate PowerShell Direct, we can on line 14 do an 11 00:00:37,990 --> 00:00:42,740 Enter‑PSSession, and notice that I'm using the VMName parameter. 12 00:00:42,740 --> 00:00:46,420 Let me run this selection, and I'm going to authenticate with an 13 00:00:46,420 --> 00:00:51,160 account on that virtual machine. And I haven't yet renamed the local 14 00:00:51,160 --> 00:00:54,710 administrator account, which is why I'm providing it here. So now we 15 00:00:54,710 --> 00:00:56,880 can see I'm connected to server1. 16 00:00:56,880 --> 00:00:58,060 If I do a host name, 17 00:00:58,060 --> 00:01:02,830 it's server1. It's kind of weird that it echoes the host name twice in 18 00:01:02,830 --> 00:01:06,370 the remoting session. I'm not exactly sure why it's doing that. But 19 00:01:06,370 --> 00:01:09,940 that's a good demonstration of PowerShell Direct. 20 00:01:09,940 --> 00:01:12,110 Let me Exit‑PSSession, 21 00:01:12,110 --> 00:01:16,640 clear the screen, and the other way to do remoting is Invoke‑Command. And 22 00:01:16,640 --> 00:01:20,360 here again we're using the VMName parameter, and I'm going to get the 23 00:01:20,360 --> 00:01:24,150 status of the WinRM service on that machine. Again, 24 00:01:24,150 --> 00:01:28,490 I have to authenticate, but let me provide that, and then we get the results 25 00:01:28,490 --> 00:01:34,310 back from that server. Okay. We can also create a persistent session object, 26 00:01:34,310 --> 00:01:37,660 like you see here, and then do a Copy‑Item. 27 00:01:37,660 --> 00:01:42,550 So we could say, first of all, authenticate to server1 as a local 28 00:01:42,550 --> 00:01:46,460 administrator and then copy an item from the local path, 29 00:01:46,460 --> 00:01:52,880 C:\scripts\new‑user.ps1 to the destination in the guest VM C:\scripts. 30 00:01:52,880 --> 00:01:56,850 And I'd probably want to create a saved credential rather than have 31 00:01:56,850 --> 00:02:00,140 to interactively put in my credentials each time. 32 00:02:00,140 --> 00:02:01,400 That's super annoying. 33 00:02:01,400 --> 00:02:03,750 But this should be the last time I do it. 34 00:02:03,750 --> 00:02:08,380 And now let's right‑click this guy and run that copy session, and I can 35 00:02:08,380 --> 00:02:12,600 verify that by going to the File Explorer on the virtual machine, and 36 00:02:12,600 --> 00:02:16,310 there's the new user script, copy it into C:\scripts. 37 00:02:16,310 --> 00:02:18,910 Okay. Same idea. Now, with PowerShell remoting, again, 38 00:02:18,910 --> 00:02:22,850 it's literally the same thing, only instead of VMName, 39 00:02:22,850 --> 00:02:24,430 we're using ComputerName. 40 00:02:24,430 --> 00:02:27,160 So we could do the same thing as far as entering a 41 00:02:27,160 --> 00:02:30,160 PSSession or doing an Invoke‑Command. 42 00:02:30,160 --> 00:02:33,670 That's what I'm going to do here. Let me change the WinRM to a different 43 00:02:33,670 --> 00:02:37,720 service, but other than that, I'll do it the same way, and I'll do again 44 00:02:37,720 --> 00:02:41,640 Credential (Get‑Credential). Clear the screen, and let's try this. Now 45 00:02:41,640 --> 00:02:46,370 this assumes that server1 is already enabled for PowerShell remoting, 46 00:02:46,370 --> 00:02:50,940 which I've mentioned a few times is the case by default on Windows Server. 47 00:02:50,940 --> 00:02:54,710 On Windows Client, you would need to enable PS remoting. In other words, 48 00:02:54,710 --> 00:02:59,540 you would need a command like you see here, this ScriptBlock section on 24 to 49 00:02:59,540 --> 00:03:04,310 enable PS remoting on a machine. To finish up, let me verify that this 50 00:03:04,310 --> 00:03:07,960 internal server1 is able to get out onto the internet. 51 00:03:07,960 --> 00:03:13,150 I'm going to do an IPv4 ping against the Syracuse University domain, 52 00:03:13,150 --> 00:03:17,810 and this is just a verification that it works. When I enabled the MAC 53 00:03:17,810 --> 00:03:21,360 address spoofing, this is absolutely critical to configure on the 54 00:03:21,360 --> 00:03:25,780 Hyper‑V host because you've got two layers of virtual switches going 55 00:03:25,780 --> 00:03:30,220 on. So you're going to have MAC addresses flying all over the place at 56 00:03:30,220 --> 00:03:31,260 different levels. 57 00:03:31,260 --> 00:03:36,170 Let's finish up by taking a brief look in Hyper‑V Manager in the VM 58 00:03:36,170 --> 00:03:40,010 Settings. Let me right‑click server1 and go to Settings from the 59 00:03:40,010 --> 00:03:42,980 shortcut menu. A little bit more about RAM, 60 00:03:42,980 --> 00:03:48,050 given that dynamic memory is mentioned specifically on the AZ‑800 61 00:03:48,050 --> 00:03:52,350 certification objectives. Notice you can adjust the amount of RAM, 62 00:03:52,350 --> 00:03:55,080 the startup RAM, while the machine is running. 63 00:03:55,080 --> 00:03:59,130 We certainly can change it after the fact, but notice that we can adjust if 64 00:03:59,130 --> 00:04:04,140 we've got dynamic memory turned on the minimum and maximum RAM allocation, as 65 00:04:04,140 --> 00:04:08,440 well as the percentage of memory that Hyper‑V should try to reserve as a 66 00:04:08,440 --> 00:04:13,150 buffer. And then here's that weight property where we can prioritize the 67 00:04:13,150 --> 00:04:18,350 availability of memory for this VM compared to other VMs on the machine. And 68 00:04:18,350 --> 00:04:22,430 there's a warning that if you set this too low, the VM might not start. If you 69 00:04:22,430 --> 00:04:23,180 set it too high, 70 00:04:23,180 --> 00:04:27,510 you may be robbing other VMs and preventing them from running optimally or 71 00:04:27,510 --> 00:04:32,170 maybe even starting up. Lastly, in order to make sure that you've got as many 72 00:04:32,170 --> 00:04:35,500 of those enhanced session configurations available, 73 00:04:35,500 --> 00:04:37,900 you'll want to make sure that you've enabled all of the 74 00:04:37,900 --> 00:04:40,250 integration services. So as you can see here, 75 00:04:40,250 --> 00:04:44,820 I've got all of them, including guest services, enabled for this virtual 76 00:04:44,820 --> 00:04:48,080 machine, and then I'll click OK to commit my change. 77 00:04:48,080 --> 00:04:53,240 We can see down in the Hyper‑V Manager, if we want to quickly get a check on 78 00:04:53,240 --> 00:04:58,550 what the TCP/IP configuration of the virtual machine is, we can head on over 79 00:04:58,550 --> 00:05:05,250 to Networking and verify the IP address, as well as the IPv6 addresses that 80 00:05:05,250 --> 00:05:09,910 may be in use on that machine, and we also see in the first column the MAC 81 00:05:09,910 --> 00:05:14,150 address that the virtual adapter is using. And actually, that's one more thing 82 00:05:14,150 --> 00:05:19,210 I forgot to show. If I go back to Settings and we go to Network Adapter down 83 00:05:19,210 --> 00:05:23,390 here, this is where you can verify the virtual switch that you're connected to. 84 00:05:23,390 --> 00:05:27,740 We also under Advanced Features can set either a dynamic or a 85 00:05:27,740 --> 00:05:32,810 static MAC address per VM and enable MAC address spoofing here. It 86 00:05:32,810 --> 00:05:36,690 says that MAC address spoofing allows virtual machines to change 87 00:05:36,690 --> 00:05:40,380 the source MAC address and outgoing packets to one that's not 88 00:05:40,380 --> 00:05:41,960 assigned to them. And again, 89 00:05:41,960 --> 00:05:51,000 that's going to be necessary when you're passing through two layers of virtual switches to reach your physical network.