Mount VHD and get drive letter

Question:

I am looking to get the drive letter of the VHD mount using Powershell. I can mount the VHD with the below cmdlet:

The mount works fine, but when I try getting the drive letter:

It fails with below error:

Get-DiskImage : Invalid property

I believe Get-DiskImage works fine for an ISO, but not for VHD? Can you help me in obtaining it for VHD.

Answer:

This way work for me:

Then Write-Output $DriveLetter will show the drive letter.

Source:

Mount VHD and get drive letter by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply