Managing Hyper-V with PowerShell

Hyper-V can be managed using the GUI or … using PowerShell! Before starting, just make sure that Hyper-V role is installed with the following command:

If Hyper-V role is not installed, run the “Install-WindowsFeature” cmdlet:

Do not forget to include the “-IncludeManagementTools” parameter because it will install the PowerShell module for Hyper-V.

Be careful, this command will force a reboot.

Now you can easily get the list of Hyper-V cmdlets by using the following command:

Output will be something like that:

hyperv

PowerShell let you accomplish most of the tasks that you can accomplish with the GUI.

Listing Hyper-V Hosts and Virtual Machines

Let’s see two examples. first, I will list my Hyper-V host and then I will list its VMs.

1- If you want to display the local Hyper-V host:

2- If you want to display all the VMs:

Many cmdlets let you display some information about your Hyper-V environment. You can list these cmdlets with the following command:

hyperv2

If you need further information about these cmdlets, you can use the “Get-Help” cmdlet.

 

Thanks for reading! You can follow me on Twitter @PrigentNico

 

About Nicolas 270 Articles
I work as an IT Production Manager, based in Paris (France) with a primary focus on Microsoft technologies. I have 10 years experience in administering Windows Servers. . I am a Microsoft MVP for Cloud & Datacenter Management. I also received the PowerShell Hero 2016 award by PowerShell.0rg. And finally, I am "MCSE: Cloud Platform and Infrastructure", "MCSA: Windows Servers", "Administering & Deploying SCCM", and CheckPoint CCSA certified.