Monitor Hyper-V with the command line (Part 2): Basic monitoring commands

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.

Monitor Hyper-V with the command line (Part 2): Basic monitoring commands Picture 1

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

Monitor Hyper-V with the command line (Part 2): Basic monitoring commands Picture 2

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.

Monitor Hyper-V with the command line (Part 2): Basic monitoring commands Picture 3

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.

Monitor Hyper-V with the command line (Part 2): Basic monitoring commands Picture 4

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.

Monitor Hyper-V with the command line (Part 2): Basic monitoring commands Picture 5

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.

4 ★ | 7 Vote

May be interested

  • What is PowerShell Basic commands in PowerShellWhat is PowerShell Basic commands in PowerShell
    what is powershell basic commands in powershell. first of all, to understand it briefly, powershell is a command-line interface similar to cmd, it can do everything cmd can do and even more. powershell is gradually becoming the default
  • Basic Shell commands in LinuxBasic Shell commands in Linux
    working on the linux operating system you cannot not know the basic shell commands. for ease of operation on linux, tipsmake.com has compiled some basic linux shell commands, please consult.
  • 10 commands Windows 7 network administrators need to know10 commands Windows 7 network administrators need to know
    in this tutorial we will show you 10 basic commands that can be performed on the command line tool in windows 7.
  • How to use Terminal on a MacHow to use Terminal on a Mac
    terminal on mac is a command line interface that allows you to use unix commands to complete some tasks much faster than using a graphical user interface (gui). with the terminal command, you can open files, improve your mac's performance, and more. here's how to use terminal on mac, including some basic commands you can get started.
  • Learn Pktmon: Windows 10's built-in network monitoring toolLearn Pktmon: Windows 10's built-in network monitoring tool
    when it released its windows 10 october 2018 update, microsoft silently added an integrated command-line packet sniffer called pktmon to windows 10. since then, microsoft has added one more. number of features for this tool to make the user easier to use.
  • 10 best Ping monitoring software and tools10 best Ping monitoring software and tools
    ping monitoring is a common practice used to check the availability and status of network devices and computers using the icmp protocol.
  • Summary of the common Run CMD commandsSummary of the common Run CMD commands
    instead of performing manual and direct access operations on windows, we can replace existing cmd commands for faster access.
  • Learn about the management and monitoring functions of Resource Monitor toolLearn about the management and monitoring functions of Resource Monitor tool
    in the following article, we will show you some of the features and usage of the handy resource monitor tool from microsoft, which is used to manage and monitor the operation of the network system. storage capacity and system performance ...
  • 10 useful commands in Windows you should know10 useful commands in Windows you should know
    command prompt is used to execute batch files, perform tasks quickly, help you troubleshoot and solve some windows problems when the system crashes. however, not all commands in windows are useful and must be done regularly. with the 10 command lines in the following article it is very useful even if you are not an administrator.
  • Install Windows Hyper-V Server 2008Install Windows Hyper-V Server 2008
    in this article, i will show you how to install microsoft hyper-v server 2008 and use the hvconfig command-line tool.