Hyper-V – PowerShell – Create VM

email me

Create a VM using PowerShell.

* This assumes Hyper-V is installed

 

$VMName = "myVM1"

$VM = @{
Name = $VMName
MemoryStartupBytes = 4294967296
Generation = 2
NewVHDPath = "D:\VM\$VMName\$VMName.vhdx"
NewVHDSizeBytes = 107374182400
BootDevice = "VHD"
Path = "D:\VM\$VMName"
SwitchName = (Get-VMSwitch).Name
}

New-VM @VM

 

Notes

New-VM

Get-VMSwitch

see Hyper-V Cmdlets

 

Install-WindowsFeature -Name Hyper-V -ComputerName TheComputerName -IncludeManagementTools -Restart

 

 

tags: MrNetTek