how can i restore a corrupted VHDX HD by using power shell

high every body

i have a problem with vhdx corrupted via email and i need to repair it by using Power shell i wrote



$VHDService = get-wmiobject -class “Msvm_ImageManagementService” -namespace “root\virtualization
\v2” -computername “.”

then i wrote


i got the following massage:

Method invocation failed because [System.Management.ManagementObject] does not contain a method named ‘mount’.
At line:1 char:1

  • $result=$VHDservice.mount($vhdName)
  • CategoryInfo : InvalidOperation: (mount:String) , RuntimeException
  • FullyQualifiedErrorId : MethodNotFound

can any body help me

Hi Aadam,

Which version of PowerShell are you using? The above script works only with PowerShell 2.0, if you are using the higher PS Version, use the commands below…



Mount-DiskImage -ImagePath $VHDXName


Mount-DiskImage function comes with the Storage module, if you have Hyper-V PowerShell modules is installed and imported, you can Mount-VHD CmdLet.



Mount-VHD -Path $VHDXName


To dismount the VHD/DiskImage you can use the following commands



Dismount-DiskImage -ImagePath $VHDXName # With the Storage module

Dismount-VHD -Path $VHDXName # With the Hyper-V module


Thank you.

Its not depended on PowerShell version, its with WMI and will work with later versions as well. The problem here is the Mount method is not seen in the available method list for this class, but its documented in MSDN.

$VHDservice | Get-Member -MemberType Method

Please do not follow the MSDN topics, most of them are outdated.

Please refer to Microsoft Docs.

Thank you.

Thanks, that one is outdated and the method to mount seems to be like AttachVirtualHardDisk()

Yes, you are right “AttachVirtualHardDisk” method serves the purpose here. Instead you can use strait CmdLet [pre] Mount-DiskImage [/pre]

Thank you

Thanks alot for your kind support

i used : Mount-VHD -Path $VHDXName
and i had the following massage :
Mount-DiskImage : The file or directory is corrupted and unreadable.
At line:1 char:1

  • Mount-DiskImage -ImagePath $VHDXName
  •   + CategoryInfo          : NotSpecified: (MSFT_DiskImage:ROOT/Microsoft/.../MSFT_DiskImage) [Mount-DiskImage], CimException
      + FullyQualifiedErrorId : HRESULT 0x80070570,Mount-DiskImage

how can i mount this hard

thanks alot

Then, in that case, create a VM, attach this VHD and start the VM, mostly it will scan and fix the issues while the operating system is booting. If it is still not resolved then you need to depend on some command line tools available online. Thank you.