PowerShell One-Liner: Create a new Hyper-V VM

My test environment resides on a workstation that runs Windows 8.1 Enterprise Edition with the Hyper-V role enabled. I need to create a new VM that will be used as a second domain controller in my test environment.

I'll use a PowerShell one-liner to create this new VM which will use a differencing disk based on a Windows Server 2012 R2 vhdx that has been fully patched and syspreped:

1New-VM -Name 'DC02' -VHDPath (
2New-VHD -Differencing -ParentPath 'D:\Hyper-V\Virtual Hard Disks\template\Server2012R2Core-Template.vhdx' -Path 'D:\Hyper-V\Virtual Hard Disks\dc02.vhdx' -SizeBytes 127GB
3).Path -MemoryStartupBytes 512MB -SwitchName 'Internal Virtual Switch' |
4Set-VM -ProcessorCount 2 -DynamicMemory -MemoryMinimumBytes 512MB -MemoryMaximumBytes 2GB -Passthru |
5Start-VM -Passthru

create-dc02-vm1.jpg

µ