Fast Create Hyper-V VM

This is a script to quickly create a VM, mostly for tests

 

Quickly create a VM with 512MB Ram on local Hyper-V host
[sourcecode language=”powershell”]
New-VM -Name testvm01 -Path ‘C:VMs’ -MemorystartupBytes 512MB
[/sourcecode]
Quickly create a VM with 512MB Ram on remote Hyper-V host
[sourcecode language=”powershell”]
New-VM -Computername ‘hypervhostname’ -Name ‘vmname’ -Path ‘c:VMs’ -MemorystartupBytes 512MB
[/sourcecode]
Create multiple VMs on a remote host using a list.

Create a txt file with VM names, like this:

name
testvm01
testvm02
testvm03

The command:
[sourcecode language=”powershell”]
Import-Csv C:list.txt | foreach { New-VM -ComputerName ‘hypervhost’ -Name $_.name -Path ‘c:VMs’ -MemorystartupBytes 512MB}
[/sourcecode]
 

Share