As with most of Microsoft’s products nowadays, you can either use the GUI or use Powershell.

When you wish to create a new virtual machine in Hyper-V, you can either use the Hyper-V Manager or create the Hyper-V virtual machines using Powershell.

Using Powershell allows you to create Hyper-V virtual machines using templates systematically, and you can also automate the whole process.

In this blog post, I cover how to create Hyper-V virtual machines using Powershell.

How to create a VM using Powershell in Hyper-V

Start by opening an elevated Powershell window.

Enter the command below to create a new virtual machine with a startup RAM memory of 512 GB

New-VM -Name DC -MemoryStartupBytes 512MB -Path D:\ws2012.local

Note that a subfolder is created with the name of the virtual machine. So in my case, the virtual machine will be placed in D:\ws2012.localDC.

Create a VM using the Powershell command New-Vm

The next step is to create a new dynamically expanding Virtual Hard Drive with the *.vhdx file extension and with a maximum size of 60 GB using:

New-VHD -Path D:\ws2012.localDCDC.vhdx -SizeBytes 60GB -Dynamic
New Virtual Hard Drive VHDX Powershell Windows Server 2012

The next step is to connect the newly created Virtual Hard Drive with the virtual machine.

Add-VMHardDiskDrive -VMName DC -Path D:\ws2012.localDCDC.vhdx" 

Connect a *.iso file for the Windows installation:

Set-VMDvdDrive -VMName DC -ControllerNumber 1 -Path "<path to ISO>
Connect DVD Iso Virtual Machine Powershell Windows Server 2012 Hyper-V

Start the virtual machine:

Start-VM –Name DC

View the status of the virtual machine:

Start Virtual Machine Powershell Windows Server 2012 Hyper-V

I also prefer to set up dynamic memory for my machine. This means that the virtual machine will only use the memory required.

To accomplish this, you first need to stop the machine using:

Stop-VM DC

Then run:

Set-VMMemory -VMName DC -DynamicMemoryEnabled $true -StartupBytes 512MB -MinimumByte 512


There are of course a lot more settings you can configure, but this will get you up and running. Once you get the hang of Powershell, you won’t be going back to create your machines in the GUI, as this is much faster and less error-prone πŸ™‚

How do you create virtual machines in Hyper-V? Please leave a comment below!

Suggested Resources


  1. After you build the virtual machine using Powershell inside the Hyper-V server 2012. (Let say I instill Windows Server 2012 or Windows 8 onto that virtual machine.) Can I build & manager any & all other virtual machines form the GUI on that virtual machine (Windows Server 2012 or Windows 8)? Thank you for your help and time. Have a nice day.

  2. Hi Daniel,

    thank you for the script.

    I also tried to disable checkpoints via PowerShell because I use Hyper-V with Windows 10 Pro and the following command just didn’t work:
    Set-VM -Name $Name -AutomaticCheckpointsEnabled $False

    Set-VM doesn’t support the parameter AutomaticCheckpointsEnabled right now. I can’t find the source but I read it will change with Windows Update 1907 (yet to be released).

    Hope this helps someone finding this resource.

    Anyway thank you

  3. Can’t remember which blog post took me over here from the beginning, but never mind. Thanks for that one.

    One PS script being used frequently by me is one that deploys a few VM’s for test and lab. For that task I use Parent/Child configuration with differencing disks. Maybe that’s another blog post for the future…? πŸ˜‰

    Ooh, almost forgot. It’s a small world. We’ve almost been neighhours back in the days, wen’t to school with your little sis’.

    Cheers from Kungsbacka


Please enter your comment!
Please enter your name here