Monitor Hyper-V with the command line (Part 2): Basic monitoring commands
In this article, we will learn how to access the virtual machine list and see general information about virtual machines with simple PowerShell statements. We will also look at stop commands and start virtual machines from the command window.
TipsMake.com - In this article, we will learn how to access the virtual machine list and see general information about virtual machines with simple PowerShell statements. We will also look at stop commands and start virtual machines from the command window.
>>>Monitor Hyper-V with the command line (Part 1): Install the monitoring library
If you have read the first part of this series, you already know how to install the Hyper-V monitoring library. Now is the time to reap the benefits of the installation process by monitoring Hyper-V from PowerShell.
Each time you open PowerShell, you will have to enter the Hyper-V monitoring library before you can use any of the commands below. The command to enter the monitoring library is:
Import-Module 'C: Program FilesModulesHypervHyperv.psd1'
Basic monitoring commands
Hyper-V monitoring library supports a lot of commands, here are some basic commands that users can perform from PowerShell.
If you want to see the virtual machines that exist on the Hyper-V server, use the following command:
Get-VM
This command displays a table representing each virtual machine and host name that the virtual machine currently exists on (this is particularly convenient for large clusters that a virtual machine might be running on a particular cluster). . The Get-VM command also shows the user the current state of each virtual machine as well as the time the virtual machine is running. The table also contains an owner field (owner field).
Now you know how to get a list of virtual machines on your server. Assuming you want to see some more information about a specific virtual machine, use the Get-VMSummary statement with the name of the virtual machine you want to check.
The following figure shows the operation of the Get-VM and Get-VMSummary commands. As you can see, the Get-VMSummary statement displays the virtual machine name, IP address, operating system, and some other statistics.
In addition, there are several variations of these statements. For example, if you want to get a list of virtual machines from a specified server named Main, just add the '-Server' parameter after the Get-VM command:
Get-VM-Server Main
Similarly, we can get summary information from a virtual machine on the remote server. For example, if you want to see information about a virtual machine named DNS on the Main server, use the command:
Get-VMSummary DNS-Server Main
Of course, the Hyper-V monitoring library is even more useful than just collecting virtual machine information. It can also launch and stop virtual machines with the command line. The command we use to launch the virtual machine is: Start-VM .
When executing this command, you will receive a background activity warning message, as shown below. This message can be ignored because it simply shows that the virtual machine is starting and that the initialized WMI has been lined up.
In fact, if you read the warning carefully, you will notice that PowerShell gives you a WMI identifier as well as the cmdlets that will be used to check the status.
Use the Stop-VM command to stop the virtual machine. The command basically pushes the virtual machine into a state of being stopped, so to turn off the virtual machine, it is better to use the invoke-VMShutdown command. This command actually tells the virtual machine operating system to perform a shutdown. Of course, this statement is designed to be used for virtual machines using the Windows operating system.
In the picture below, you can see that I first entered the Stop-VM command. When PowerShell asks if I really want to stop the virtual machine, I cancel it by pressing N. Then, use the Invoke-VMShutdown command (with the virtual machine name) to start the shutdown process. Again, PowerShell asked me if I really wanted to do this. This time I entered Y and the shutdown process started. Finally, check that the virtual machine is turned off with the Get-VM command.
Now you know how to check the virtual machine's overall information and how to start and stop the virtual machine from the command line interface. In Part 3, I will show you two troubleshooting commands, PingVM and TestVmHeartBeat. Next are some tricks to adjust memory allocation for virtual machines.
You should read it
- Monitor Hyper-V with the command line (Part 3): Check virtual machine status
- How to import Hyper-V virtual machines in Windows 10
- How to export Hyper-V virtual machines in Windows 10
- How to rename Hyper-V virtual machines using PowerShell and Hyper-V Manager
- Monitor Hyper-V with the command line (Part 1): Install the monitoring library
- Monitor Hyper-V with the command line (Part 4)
- Use the Virtual Machine Manager to quickly deploy Hyper-V
- Create virtual machines in Hyper-V on Windows Server 2008
- How to check if your computer is running Windows 10 Hyper-V?
- Collect the Process ID information or GUID of Hyper-V Virtual Machine
- Create virtual machines with Hyper-V on Windows 8 and Windows 10
- Setting up Ubuntu virtual machine with Hyper-V Quick Create on Windows 10
Maybe you are interested
Why choose lemon water to lose weight? How much does the flower pistil cost? Where to buy quality assurance? Effect of saffron pistil with health and beauty How to clean oven extremely simple and effective Rounded eyes with 7 bizarre prohibitions can only exist in the Middle Ages What terrible thing will happen when not wearing protective gear in space?