Microsoft Azure AZ-800 — Section 11: Manage Hyper-V and guest virtual machines Part 2

Microsoft Azure AZ-800 — Section 11: Manage Hyper-V and guest virtual machines Part 2

83. Manage VM using PowerShell Remoting, PowerShell Direct, and HVC.exe

OK now like to take a look at some different ways that we can remotely administer our virtual machines using PowerShell.

So the first way that we can remotely minister our virtual machines using PowerShell is from the host computer itself.

So here I am on the host computer that’s hosting the virtual machines. And if I wanted to run PowerShell and get into those virtual machines and run commands, I can use something called PowerShell Direct.

Now, PowerShell Direct does require that the virtual machines do have the winner in service running and all that. And don’t forget there’s a command called winner in quick config winner in space quick config. You can run on your virtual machines that can make sure all that is turned on.

OK, if you’ve gone through the PowerShell lessons in the past, you’ve seen that already. But anyway, what I’m going to now do is open up PowerShell on this host computer. I’m going to right click start and I’m going to go to PowerShell and we can run this little command right here into -PSA session, -VM name and then the name of the virtual machine.

So, in my case, for when it connected to NYC Server one, I’m going to do that.

So, I’m going head hit here. And then from there you’ll notice that I got some credentials. I just got to put in the credentials it’s going to let me connect in.

So exam lab practice slash administrator and then the password. And if everything went successfully, I’m now connected in, as you can see, it shows right there that I’m connected.

So that point I can run commands like get process, I can see the processes running on the machine. I can say, get service, see the services running on the machine just as though I was physically connected at that machine.

So the next thing that I want to show you is that I can I can type another command and look at some of the different services and features of each VM.

OK, first thing I’m going to do is just exit out here, and I’m now no longer connected into an y’see server one. But this command is called H v c. There’s actually h b c c execuTable located in windows, and you can just run that from any prompt here, including just command prompt. You don’t even have to be inside PowerShell, but H V-C, which stands for Hyper-V CROI, that’s command line environment. This command is a way that I can just move this up a little bit. This a way that I can list out my VMS and show the state of the VM, start and stop VMS all of that.

So, for example, if I say a b c list hit Enter, you can see the virtual machines that are available here. The ones that are running course shows the stay. If you wanted to look at a specific state, you could say v c the word state hit Enter and it shows you the commands that are available for that.

OK, how about we type? Let’s just look at the state of the specific VM, so, we’ll say HBC state and then the specific VM, which is NYC -Server one, and you can see that it says that it’s running right? So see, you can see all the commands here. If you wanted to stop a VM, if he said H. V.C. stop, all you have to do is type C HPC stop and then tells you -F shuts down the VM and then the name of the VM, which I don’t want to shut my VMS down right now, so, I’m not going to do that. But if you want to try that out, you can. Ah, you can connect via S-H. You can do what’s called secure copy protocol connects into that. If there was like a serial port connected in or you want to connect to the graphic console, there’s lots of neat little things here that you can take a look at. You can even see what the IP address is. Lots of fun little stuff here that you can do in the third and final way. Thing that I want to show you is I’m actually going to connect into one of the virtual machines will connect in the NYC DC one. And of course, you just got good old PowerShell remote that you’ve had in the past.

So, I can go to PowerShell here on inwhat CDK1 and I can remote in from NYC DC one to NYC Server one as long as they’re connected to the same network and all that.

So, for example, I can say get -process, -computer name NYC -SVR one, and that’s going to show the process is running on NYSE Server one.

OK. You can also, invoke a script if you want. You can say Invoke, Command, -Computer Name, NYC Server one, and then if you had a script, you could specify a script that you want to run. And you can also connect directly into that session. Enter Dash. Peace session, computer name, NYC -Server one, and now I’m connected directly into it just like I was from the host machine a minute ago. Every command that I run is now going to run on that machine, including if I create a directory called J.C. was here.

So just in case the air. Let’s see Swiss voting already exist. That’s right, I did that demo already, actually. How about we do this? We’ll say again, Jaycee was here again. All right. And so, we’ll jump back over there to NYC Server one. Open up File Explorer and we should be able to go to see drive and see that was created. Yes, there was the original. Here’s the newer one. All right. And so, it did work. And those are the different ways that you can remotely administer your virtual machines with the help of PowerShell.

84. Configure VM memory

I now want to discuss virtual machine memory with you now, as you can see here on my Hyper-V machine, I’ve got a couple of virtual machines that are already configured. And you can see how much memory they have now. The memory was initially set up when these virtual machines were created. I assign how much memory that they can get. All right now, if you want to adjust this, you can click on one of the virtual machines and then just come over here to the right and you’ll see an option down here. That’s the settings under the machine. Or you can just right click the machine and go to settings that way, either way or work, and then click on the memory button here or the memory option right here. And you can adjust memory now. I can. This known as a Generation two virtual machine. I can adjust the RAM settings here, but I can’t turn on dynamic memory while this virtual machine is turned on.

Now, you could shut this virtual machine down and then you can adjust. I’m just going to use one of these other virtual machines that have nothing. But if you’re if you’re trying to play around with this yourself, you might have to shut down one of your virtual machines in order to do this. But I’m just going to right click one of these that’s all in. If I go to settings, you’ll notice I can get a memory in, then I can go to enable dynamic memory.

So what is dynamic memory? Dynamic memory allows you to set a minimum and maximum the minimum amount of memory that machine is going to start out with and then the maximum that it can grow to. Essentially, that means that you’re going to allow the virtual machine to keep consuming more memory if it needs it. This obviously important for servers. If they need more memory, you want to be able to grow into that and use that memory. Of course, the problem you run into is if you have multiple virtual virtual machines running, those virtual machines can start fighting over memory and consume a certain amount of memory. The other thing that you want to make sure of is that when virtual machines are coming up, there is enough memory for the virtual machine to start.

So you’ll notice there’s an option here called memory buffer, and it tells you right here that to specify the percentage of memory that Hyper-V should try to reserve as a buffer. And so this reserved so that when that virtual machine tries to start, it’s got enough memory to start because what you don’t want to happen is for the virtual machine to start and then some of the services start loading up and then, oh no, there’s not enough memory and then things get could get corrupted or crash. This way, you’re guaranteed that in order for the virtual machine to start, there is enough memory. There’ll be 20 percent of the memory that’s needed in order to do that against this, the ram that you’ve allocated. The other thing is, if there are conflicts where virtual machines are fighting over memory, you have ability to set a memory weight.

So, for example, if I come over here to DC one, maybe DC one needs more memory. I can go to settings and I could set the memory rate to high and then maybe four server one right here. Server one is just set down to a medium rate, so he’s a little lower.

So that means that DC one would be able to get more memory if it needed, if I’m going to support the machine’s conflicting and doing dynamic and memory features. All right.

So that is what your memory weight is, and that is how you essentially control the memory settings on your virtual machine. Just keep in mind that that you may have to shut your virtual machine off if you’re going to. If you, well, there’s no me about it, you’re going to have to shut your virtual machine off if you’re going to adjust the dynamic memory. If you are going to use a dynamic memory feature, are really, you know, don’t generally use the Dynamic Memory feature when I am doing demonstrations. This the reason why I don’t have this enabled right now on my machine. But if you wanted to use it in the real world, it can be helpful because you can allow the virtual machines to have a minimum and then grow into a maximum.

85. Configure Integration Services

Another great feature that comes with Hyper-V is a feature called Hyper-V Integrated Services.

Now, Integrated Services allows the Hyper-V host machine to communicate with the guest virtual operating systems virtual machines in a way that allows information to be shared between the host and those virtual machines. Of course, we get to choose what information is going to be shared between the host and the virtual machines, and we can do that by right clicking one of our virtual machines, clicking settings and then underneath management. Here you’ll see integrated services, and this where you can turn on or off whatever you want.

So for one, I’ve got operating system shut down. I can instruct my Hyper-V to go ahead and shut down my VM VMS if I want. I can do time synchronization, which allows my Hyper-V to synchronize the time with it with the time servers on the internet. This helpful, very important for things like Kerberos on two domain controllers and all that. We’ve got data exchange. This allows metadata information to be exchanged between Hyper-V and the VMS, so the VMS can share certain pieces of information with Hyper-V. You’ve got a heartbeat. This a way to make sure that the without having to connect into the virtual machine, the virtual machine is letting Hyper-V know that it’s still up and running and everything is OK. Then you got backup volume shadow copy. This going to allow the virtual machines to be backed up while they’re being used. And then lastly, you have a guest services. Guest services will allow things like files to be transmitted between the Hyper-V host and the virtual machine.

Now the reason this turned off by default is that you can’t argue that there is a security risk here. A lot of people like to do what are called sandboxing of their VMS, meaning they sever ties between file transfers between the host and the VM. And this the reason they do. This because hackers that have potentially gotten access to a VM can do something called VM escaping where they might have a file or something that’s ran for the virtual machine host against the virtual machine or from the virtual machine itself, the guest operating system against the host, some type of malware infection or something like that. And so guest services is not always turned on, usually not terminal by default, but it is something you can turn on. And then at that point, essentially you can click OK, and you’ve now turned on any additional integrated services that you want. And as you can see down here at the bottom, there’s the heartbeat and all that stuff. It’s showing me some information, and I’ve now officially got my integrated services working on that VM.