simply you have to have Hyper-V Role installed on the machine where the task will be executed.

start your Powershell Console

set variable as the class we would like to use like the below

$var = commandlet

and as we will use WMI class to deal with the VHD we have to use command called get-wmiobject this allow us to use the Msvm_ImageManagementService from the Virtualization namespace which is located under rootVirtualization and on the local computer by using –computer . or we can replace the . with remote computer name

Get-WmiObject Msvm_ImageManagementService -namespace “rootvirtualization” -computername .

so we need to use method named CreateDynamicVirtualHardDisk in Msvm_ImageManagementService class to create our dynamic disk.

Note: to get the methods you can pipeline the command above with get-member command like in the picture below.


so to get back on how to execute a method we have to insert our WMI Class in variable by typing

$disk = Get-WmiObject Msvm_ImageManagementService -namespace “rootvirtualization” -computername .

then to call the method by typing $var.method()

$disk.CreateDynamicVirtualHardDisk(“C:dynamic.vhd”, 20000000000)

and as this method requires two input 1st is the VHD path location and the second is the size in bytes

as in the example the 20000000000 will create 20 GB

now the command should be executed and display


if you go and inspect the file using your hyper-v


so we have two lines to create the VHD disk

$disk = Get-WmiObject Msvm_ImageManagementService -namespace “rootvirtualization” -computername .

$disk.CreateDynamicVirtualHardDisk(“C:dynamic.vhd”, 20000000000)

Mahmoud Ibrahim (admin)

About the Author

Mahmoud Ibrahim has technology experience with over 18 years of IT industry. He'd worked in many organizations in many roles and expanded his knowledge across technology stacks, and he is enjoying sharing his expertise whenever possible :).
He is working as a presales expert in Micro Focus serving the international community.

View all posts by Mahmoud Ibrahim (admin)
Previous Article
Next Article