Guide: How to create and configure virtual machines in Hyper-V Server 2012 using Powershell

posted in: Blog, Hyper-V, Powershell | 2

From the CMD, type Powershell to get in to the Powershell prompt.


This will create a Virtual Machine called DC in D:\ws2012.local with 512 MB memory. Note that a subfolder will be created with the name of the Virtual Machine. So in my case, the Virtual Machine will be placed in D:\ws2012.local\DC .

Create Virtual Machine Powershell Windows Server 2012


Now we will create a new dynamically expanding Virtual Hard Drive with the new *.vhdx file extension and with a maximum size of 60 GB using:

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.

Now you might want to connect an *.iso file for the Windows installation:

Connect DVD Iso Virtual Machine Powershell Windows Server 2012 Hyper-V

Start the VM:

View the status of the VM:

Start Virtual Machine Powershell Windows Server 2012 Hyper-V

I prefer to also set up Dynamic Memory for my machine. In order to do this you first need top the machine using:

Then run:

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 🙂

2 Responses

  1. what should i do after this step
    and what should i do if im using DVD
    please help

  2. funguyjape

    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.

Leave a Reply

* Copy This Password *

* Type Or Paste Password Here *