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…
[pre]
$VHDXName=‘D:\Recuritment.vhdx’
Mount-DiskImage -ImagePath $VHDXName
[/pre]
Mount-DiskImage function comes with the Storage module, if you have Hyper-V PowerShell modules is installed and imported, you can Mount-VHD CmdLet.
[pre]
$VHDXName=‘D:\Recuritment.vhdx’
Mount-VHD -Path $VHDXName
[/pre]
To dismount the VHD/DiskImage you can use the following commands
[pre]
$VHDXName=‘D:\Recuritment.vhdx’
Dismount-DiskImage -ImagePath $VHDXName # With the Storage module
Dismount-VHD -Path $VHDXName # With the Hyper-V module
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.
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
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.