December 24, 2018 at 10:09 am #131310
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
+ CategoryInfo : InvalidOperation: (mount:String) , RuntimeException
+ FullyQualifiedErrorId : MethodNotFound
can any body help me
December 24, 2018 at 1:39 pm #131322
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...
$VHDXName='D:\Recuritment.vhdx' 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.
$VHDXName='D:\Recuritment.vhdx' Mount-VHD -Path $VHDXName
To dismount the VHD/DiskImage you can use the following commands
$VHDXName='D:\Recuritment.vhdx' Dismount-DiskImage -ImagePath $VHDXName # With the Storage module Dismount-VHD -Path $VHDXName # With the Hyper-V module
December 24, 2018 at 2:20 pm #131333ParticipantPoints: 1,086Rank: Community Hero
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
December 24, 2018 at 2:46 pm #131334
Please do not follow the MSDN topics, most of them are outdated.
Please refer to Microsoft Docs.
December 24, 2018 at 3:17 pm #131336ParticipantPoints: 1,086Rank: Community Hero
Thanks, that one is outdated and the method to mount seems to be like AttachVirtualHardDisk()
December 24, 2018 at 3:56 pm #131349
Yes, you are right "AttachVirtualHardDisk" method serves the purpose here. Instead you can use strait CmdLet
December 25, 2018 at 11:52 am #131456
December 25, 2018 at 11:58 am #131459
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
December 25, 2018 at 12:09 pm #131462
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.
You must be logged in to reply to this topic.