Monday, January 30, 2017

Is it possible to use PowerShell to work with Hyper-V?

The short answer is yes. On a Windows 10 machine you can use Hyper-V to work with VMs. On a Windows 10 machine you need to enable Hyper-V using the 'Turn Windows features on or off' pop-up from the Program and Features in the Control Panel. When you enable it you should be able to see this.

You can then search for Hyper-V and start the GUI.

Clicking on Hyper-V Manager brings up the graphic user interface.

Hyper-V with PowerShell

It is also possible to use Hyper-V PowerShell module to simplify and automate management tasks. Most of what you do on the GUI can be carried out using PowerShell.

The advantages of using PowerShell is that you can automate most of the actions with flexibility. It can also provide you with features not implemented in the GUI.

If Hyper-V is already present, as in the present case (or machine) you can check if the Hyper-V module is available by using the Get-Command as in the following statement after bringing up the PowerShell command prompt:
Get-Command -module Hyper-V

This brings up the following response when run. The following is a screen shot of PowerShell ISE from the present machine. I have only included a portion of the result and most commandlets are named after their task.

For example:

Get-VMHOST gets the host information as shown.

PS C:\Users\Jayaram> get-vmhost

Name      LogicalProcessorCount MemoryCapacity(M) VirtualMachineMigrationEnabled
----      --------------------- ----------------- ------------------------------
HODENTEK8 8                     8116.2734375      False

PS C:\Users\Jayaram> get-vmhost|Select *

Just peruse the list and you can do many things with PowerShell.

If you are looking for installing Hyper-V on Windows 8.1 or Windows 10 go here:

Install Hyper-V on Windows 10:

Install Hyper-V on Windows 8.1:

No comments: