Windows > Virtualization

Virtual machine in Hyper V server using powershell command

(1/1)

mohitht:
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  :)

Navigation

[0] Message Index

Go to full version