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


John is currently creating digital assets that protects people and their future, a technical trainer and a full time geek specializing on development and deployment of innovations created with .NET framework on Windows platform as well as Windows infrastructure projects. He is the primary contact of the Philippine Windows Users Group, a contributor at the Microsoft Philippines Community forums and regularly conducts community sessions as well as other Microsoft technology events. John owns the Busy Saving The World Techblog.

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 )

Google photo

You are commenting using your Google 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 )

Connecting to %s