How to Repair Corrupt and Damaged VHD File

As we know that the VHD stands for Virtual Hard Disk and it stores very crucial data. In any situation, your .vhd file gets corrupted and inaccessible. Then you have two options, either repair VHD file by PowerShell command or repair damaged VHD file by creating the virtual server. Let’s discuss both methods in detail.

Method 1:

PowerShell empowers the user to automate the process. But the commands are hectic to use if you are not familiar with formats of commands. So I recommend you to first take backup and then execute the PowerShell command to repair corrupt VHD file. Run the command on PowerShell CMD:

  1. Choose what VHD we want to mount $VHDName = “V:\serverx.vhd“
  2. Get the MSVM_ImageManagementService
  3. $VHDService = get-wmiobject -class “Msvm_ImageManagementService” -namespace “root\virtualization” -computername “.”
  4. Now execute this command to mount vhd file
  5. $Result = $VHDService.Mount($VHDName)

Method 2:

The user can also repair corrupt VHD file by creating new virtual machine and after that link or add the damaged VHD file to the newly created virtual machine and then compact it. To complete this process performs the steps listed below:

  1. First, create the new virtual server and attach new hard disk.
  2. Now click on Setting and add newly created hard disk. After that browse the VHD file in it.
  3. Here hit on Virtual Disk Wizard and then select the Compact option. There should be Convert it to a Fixed Size Virtual hard Disk check-box checked.
  4. At the end Save this VHD file by new name. You can also save by original file name.