Monitor Hyper-V with the command line (Part 1): Install the monitoring library

One of the obvious shortcomings of Hyper-V is the ability to monitor virtual machines from Windows PowerShell. Although Microsoft intends to provide this capability on Windows Server 8, users can fully monitor virtual machines from the command line interface at this time. The article will guide you to do this

TipsMake.com - One of the obvious shortcomings of Hyper-V is the ability to monitor virtual machines from Windows PowerShell. Although Microsoft intends to provide this capability on Windows Server 8, users can fully monitor virtual machines from the command line interface at this time. The article will guide you to do that.

Get the Hyper-V monitoring library

Although Hyper-V does not provide local PowerShell monitoring features, there is a PowerShell monitoring library that can be downloaded from CodePlex. The current release is only designed to work with PowerShell version 2.0.

Prepare to install

Before installing the Hyper-V monitoring library, we will need to install Windows PowerShell. Hyper-V monitoring library is designed to work with a standalone Hyper-V server, Hyper-V works in Server Core or servers running Windows Server 2008/2008 R2.

PowerShell can be installed by opening the Server Manager-console, selecting Features and clicking the Add Features link . The Add Features installation window will ask what features users want to install. Select the Windows PowerShell feature integrated Scripting Enviroment then follow the instructions to complete the installation process.

Install hyper-V monitoring library

After downloading the Hyper-V monitoring library from the link above, we get a ZIP file containing:

  1. Install.cmd: Is the library installation file.
  2. PC_Console.REG: Update the registry for the server to be compatible with Hyper-V monitoring library.
  3. A Hyper-V directory: This directory contains data for creating libraries.

Right-click Install.cmd and select Run as Administrator from the context menu. Windows will open a command prompt and display a PowerShell Module for Hyper-V message to make sure that the .NET Framework and Windows PowerShell are all installed on the server. Press any key to continue. Then the user will receive a string of error messages as shown below.

Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 1Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 1

These error messages are harmless. The reason we see them is because the installation file is designed to be used for Server Core. Press any key to update the registry for the server. After pressing, the file installs using the PS_Console.REG file to modify the server's registry.

Next, press any key to download PowerShell. When PowerShell loads, there will be an error message saying the Hyper-V module cannot be imported.

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

Although the above error is harmless, it means that the user will have to complete the installation process manually. Fortunately, the implementation process is relatively easy.

Import Hyper-V modules

Use the following PowerShell command to import the Hyper-V module:

Import-Module 'C: Program FilesModulesHypervHyperv.psd1'

Remember to run PowerShell under Administrator (Run as Administrator) before executing the new command to import the module.

To run PowerShell as an administrator, right-click the PowerShell icon and select Run as Administrator from the context menu.

Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 3Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 3

When PowerShell opens, enter the Get-ExecutionPolicy command. Next, enter the Import-Module command above to import the Hyper-V module.

Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 4Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 4

If you receive an error message when trying to import the Hyper-V module, the problem may be that Windows blocks the scripts from the Internet. Unblock the script by opening Windows Explorer and accessing the folder C: Program FilesModulesHyperv. Now, right-click on the first file in the folder and select Properties from the context menu. When the properties sheet appears, click Unblock then click OK . Repeat the process for each file in the directory.

Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 5Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 5

Use Hyper-V monitoring library

After entering the Hyper-V module, there are many commands (cmdlets) that we can use. For example, if we enter Show-HyperVMenu, we will see a text monitoring interface for Hyper-V. This interface provides functionality similar to Hyper-V Manager.

Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 6Monitor Hyper-V with the command line (Part 1): Install the monitoring library Picture 6

Now, the Hyper-V monitoring library is installed and running. In the following article, we will learn some very useful commands from PowerShell.

3.9 ★ | 17 Vote