Basic Scripting for Hyper-V with PowerShell (Create and Manage VHD and VM)

Quick entry. So I need to do a lab for a client and I need to recreate a lab for them. They asked, how did you do it? They further said its really tiring going to UI route creating differencing disks and VM (That’s why!). So I told them I just to use PowerShell. This is being done on My Windows 8 Desktop with Hyper-V installed.


Command is

New-VHD -ParentPath "<path>.vhdx" -Path "<path>.vhdx"


How about VM?

Note: Just make sure you run as an administrator!

New-VM -Name "<name>" –MemoryStartupBytes <int>GB -SwitchName "<Switch Name>" –Path "<Where you want to save>" –VHDPath “<Path\VHD.vhdx>”


As you can see, you do not have the parameter to configure how many virtual cores to be assigned to this VM. You do this:

Set-VMProcessor “<name>” –Count <int>


This is also true for Dynamic Memory:

Set-VMMemory <VM Name> -DynamicMemoryEnabled $true



All info of  these are available at TechNet (Hyper-V Cmdlets in Windows PowerShell):


Published by


I'm John and in the daytime I am the Chief Technology Officer of VFTS.NET - a consulting firm that specializes on development and deployment of business solutions created with .NET framework on Windows platform and Windows infrastructure projects. I am a core member of the Philippine Windows Users Group, a contributor at the Microsoft Philippines Community forums and I regularly conduct technical sessions as well as other Microsoft technology events. I am a Microsoft Most Valuable Professional in the Cloud and Datacenter Management Technical Expertise but away from any keyboard I spend hours reading books, travel, explore, and being busy with my dog named Floppy.

2 thoughts on “Basic Scripting for Hyper-V with PowerShell (Create and Manage VHD and VM)”

  1. If you do not want to leave powershell then checkout for a free hyper-v manger written in powershell, that allows you to configure the vhost virtual paths, create vswitches, create.manage and connect to vm’s and then run reports on what you just created.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s