Hyper-V, Hyper-V v2, Resources, Scripting, Server 2008 R2, Virtual Server, Windows, Windows 7
comments 5

Shell extensions for virtual hard disk files

I just released a VBScript on MSDN code gallery that supports enabling VHD shell extensions. This VBScript enables the following actions in the right-click context menu of VHD files.

  • Compact VHD
  • Convert VHD
  • Expand VHD
  • Inspect VHD
  • Retrieve VHD details like,
    • Is VHD in use?
    • Type of a VHD
    • Is the VHD in saved state?
    • What are the Max Internal Size and File Size values in GB?
    • VM to which a given VHD is connected

Earlier, as you may remember, I developed a small VBScript to enable mount and unmount of VHD files from the right-click context menu. While that was really helpful, the feature set was limited. There are many other actions we can perform on a VHD from Hyper-V manager MMC console. This new tool will include all those actions within the context menu for VHD files.

Why this important?

Take an example here. You want to know which virtual machine is actually using a given VHD. To do this, using Hyper-V MMC, you need to open properties of each virtual machine and then look at IDE/SCSI controllers to find the VHD. You need to repeat this for all VMs until you find the VHD. Now, with these new shell extensions, all you need to do it double-click on the VHD or right-click and select “Detail” option. This brings up a pop up with all the details about a VHD file. That simple..! Similarly, we can perform each and every action just at the mouse click on the VHD file. No need to open any MMC conolse to perform that.

To use this, download the release from VHD Shell Extensions code gallery, copy the VBScript file to a permanent location from where you want to run the script and then at the command-prompt, just run the following command

cscript.exe VHDShellExt.vbs /action:setup

This will enable all shell extensions within the registry and when you right-click on VHD now, you must see

VHD Shell Extensions context menu

VHD Shell Extensions context menu

I will post a few follow-ups to this and then document various aspects of this tool. Hope this is helpful. Please leave your feedback here. It will help me improve the script.