Mount-VHD - no drive letter getting assigned when vhdx file mounted using mount-vhd command

Sagar Jadhav 46 Reputation points
2022-03-23T15:37:20.853+00:00

the driver letter column is empty, this command works perfectly on ws2019.
the problem is only with ws2022

PS C:\> Mount-VHD C:\10.0.20348.350.vhdx -Passthru | Get-Disk | Get-Partition | Get-Volume

DriveLetter FriendlyName FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining Size


        10.0.20348.1 NTFS           Fixed     Healthy      OK                    100.86 GB 126.4 GB
                     NTFS           Fixed     Healthy      OK                     85.41 MB   494 MB
                     FAT32          Fixed     Healthy      OK                     67.26 MB    96 MB
Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,593 questions
{count} vote

2 answers

Sort by: Most helpful
  1. Ian Xue (Shanghai Wicresoft Co., Ltd.) 31,751 Reputation points Microsoft Vendor
    2022-04-18T08:35:01.65+00:00

    Hi,

    The Mount-VHD cmdlet is part of the Hyper-V module. Please check the module versions on your servers using Get-Command Mount-VHD and see if they are the same.

    Or you can use Set-CimInstance to set the drive letter. For more details please refer to this link
    https://devblogs.microsoft.com/powershell-community/changing-drive-letters-and-labels-via-powershell/

    Best Regards,
    Ian Xue

    ============================================

    If the Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.
    0 comments No comments

  2. Victor Grusin 0 Reputation points
    2024-05-18T15:26:19.62+00:00

    The sample.

    Create file:

    C:\Scripts\Mount_VHDX_Drives.ps1

    File body:

    $VolumesVHDX = Mount-VHD -Path "C:\Disk.vhdx" -PassThru | Get-Disk | Get-Partition | Get-Volume | Select-Object DriveLetter
    Set-Partition -DriveLetter $VolumesVHDX.DriveLetter -NewDriveLetter R -Confirm:$false -ErrorAction SilentlyContinue
    

    Run this file with powershell.exe

    Command > PowerShell.exe

    Arguments > "C:\Mount_VHDX_Drives.ps1"

    https://stackoverflow.com/questions/46244143/auto-mount-vhdx-on-startup

    0 comments No comments