In this post, I will show you how to start one or more virtual machines residing on Microsoft Hyper-V using Powershell commands.
Microsoft Hyper-V module for Powershell has 164 cmdlets on Windows Server 2012 to install, configure and manage Hyper-V environment, VMs, v-switches and other components of MS virtualization.
In this article I primarily focusing on how to start one or more virtual machines using Powershell. The Hyper-V module has a cmdlet called Start-VM(similar to Start-VM in VMwareCli) to start Virtual Machines on MS Hyper-V server. This cmdlet has two important arguments named -ComputerName and -Name. The ComputerName parameter refers to Name of the Hyper-V server where the Virtual machines are hosted and Name parameter refers to actual name of the Virtual Machine that you want to start. Here please note that you should pass display name of the virtual machine that you see in Hyper-V Manager UI, not the actual Operating System name of the virtual Machine.
First of all we need to import the Virtual Machine. We can do this by executing below command from a Powershell window.
Import-Module Hyper-V
Once imported, use Start-VM cmdlet to start the Virtual Machine.
Start-VM –Name Infra1
In the above example, I haven’t provided any Hyper-V server name because by default the cmdlet tries it on local server. In my case, I am executing these commands from a shell on Hyper-V server where my VM is located.
To start a VM hosted on remote Hyper-V server, you can specify the name of remote Hyper-V server to the ComputerName parameter. See below example.
Start-VM –ComputerName MyHyperv2 –Name Infra1
Similarly you can start multiple Virtual machines by specifying their names to Name parameter as shown below.
Start-VM –ComputerName MyHyperv2 –Name Infra1,Infra2
Hope this helps and happy learning.