PowerTip: Create a New VHD with Windows PowerShell


Summary: Use Windows PowerShell to create a new virtual hard disk to use with Hyper-V.

Hey, Scripting Guy! Question How can I create a new virtual hard disk in Hyper-V?

Hey, Scripting Guy! Answer Use the New-VHD cmdlet.

This will create a 60 GB dynamic disk VHDX file under C:\VHD\ called Mydrive.vhdx:

NEW-VHD -Dynamic C:\VHD\MyDrive.vhdx -SizeBytes 60GB

This will create a 5 GB fixed disk VHDX file under C:\VHD\ called FixedDisk.vhdx:

NEW-VHD -Fixed C:\VHD\FixedDisk.vhdx -SizeBytes 5GB

Comments (5)

  1. Phillyjack says:

    Tried this under Server 2012 and it didn’t work. What am I missing?

  2. M Iqbal Qureshi says:

    “New-VHD” command does not work under ‘Server Core’ edition. Is there some way so that the “New-VHD” command should work with ‘Server Core’ of Windows Serve 2012/R2.

  3. Kevin Miller says:

    Just used on 2012 r2 core – worked perfectly.

  4. Mark says:

    it works perfectly "IF" you install Hyper-V Role otherwise you dont have those cmdlets 😉

  5. Jason Hong says:

    You have to install the module "Hyper-V Module for Windows PowerShell" which is under Features–>Remote Server Administration Tools–>Role Administration Tools–>Hyper-V Management Tools–>Hyper-V Module for Windows PowerShell

Skip to main content