Get your server issues fixed by our experts for a price starting at just 25 USD/Hour. Click here to register and open a ticket with us now!

Author Topic: Virtual machine in Hyper V server using powershell command  (Read 17173 times)

0 Members and 1 Guest are viewing this topic.

mohitht

  • Guest
Virtual machine in Hyper V server using powershell command
« on: February 08, 2014, 01:11:31 pm »
Hi All,

We can create a virtual machine in Hyper V server using the simple commands in powershell.

To create a Virtual machine follow the simple steps

Open the Powershell

type the following in terminal

The syntax for new VM creation is
New-VM -Name -Path -MemorystartupBytes

To create new VM
New-VM -Name Testmachine -path C:\vm-machine --MemoryStartupBytes 512MB

Note:
MemoryStartupBytes is the RAM for new VM

To create Harddisk for new VM we can use New-VHD command

New-VHD -Path c:\vm-Machine\Testmahcine\Testmachine.vhdx -SizeBytes 10GB -Dynamic


To attach virtual hard disk  for a Virtual Machine we can use Add-VMHardDiskDrive command

syntax is as follows
Add-VMHardDiskDrive -VMName -Path

Add-VMHardDiskDrive -VMName TestMachine -path "C:\vm-machine\Testmachine\Testmachine.vhdx"

We can map the ISO image to virtual machine CD/DVD ROM by

Set-VMDvdDrive -VMName -ControllerNumber 1 -Path

We can start new VM by

Start-VM -Name

To stop VM use the command below

Stop-VM -Name

To check the VM status
use the command below

Get-VM

That's It  :)