Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mount-DiskImage does not assign driver letter every third time #23280

Closed
5 tasks done
stephen9357 opened this issue May 10, 2024 · 4 comments
Closed
5 tasks done

Mount-DiskImage does not assign driver letter every third time #23280

stephen9357 opened this issue May 10, 2024 · 4 comments
Labels
Needs-Triage The issue is new and needs to be triaged by a work group. Resolution-External The issue is caused by external component(s).

Comments

@stephen9357
Copy link

Prerequisites

Steps to reproduce

When running the following code, Mount-DiskImage will not assign an drive letter every third time. I have no idea why the failure occurs precisely every third time。

PS C:\Users\admin> $ImagePath="C:\ISO\Windows\en-us_windows_server_2022_x64_dvd_620d7eac.iso"
PS C:\Users\admin> $disk = Mount-DiskImage -ImagePath $ImagePath -StorageType ISO -Access ReadOnly -PassThru
PS C:\Users\admin> $disk | Get-Volume

DriveLetter FriendlyName         FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining    Size
----------- ------------         -------------- --------- ------------ ----------------- -------------    ----
D           SSS_X64FRE_EN-US_DV9 Unknown        CD-ROM    Healthy      OK                          0 B 5.17 GB

PS C:\Users\admin> $disk | Dismount-DiskImage

Attached          : False
BlockSize         : 0
DevicePath        :
FileSize          : 5550684160
ImagePath         : C:\ISO\Windows\en-us_windows_server_2022_x64_dvd_620d7eac.iso
LogicalSectorSize : 2048
Number            :
Size              : 5550684160
StorageType       : 1
PSComputerName    :

PS C:\Users\admin> $disk = Mount-DiskImage -ImagePath $ImagePath -StorageType ISO -Access ReadOnly -PassThru
PS C:\Users\admin> $disk | Get-Volume

DriveLetter FriendlyName         FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining    Size
----------- ------------         -------------- --------- ------------ ----------------- -------------    ----
D           SSS_X64FRE_EN-US_DV9 Unknown        CD-ROM    Healthy      OK                          0 B 5.17 GB

PS C:\Users\admin> $disk | Dismount-DiskImage

Attached          : False
BlockSize         : 0
DevicePath        :
FileSize          : 5550684160
ImagePath         : C:\ISO\Windows\en-us_windows_server_2022_x64_dvd_620d7eac.iso
LogicalSectorSize : 2048
Number            :
Size              : 5550684160
StorageType       : 1
PSComputerName    :

PS C:\Users\admin> $disk = Mount-DiskImage -ImagePath $ImagePath -StorageType ISO -Access ReadOnly -PassThru
PS C:\Users\admin> $disk | Get-Volume

DriveLetter FriendlyName         FileSystemType DriveType HealthStatus OperationalStatus SizeRemaining    Size
----------- ------------         -------------- --------- ------------ ----------------- -------------    ----
            SSS_X64FRE_EN-US_DV9 Unknown        CD-ROM    Healthy      OK                          0 B 5.17 GB

PS C:\Users\admin> $disk | select *

Attached              : True
BlockSize             : 0
DevicePath            : \\.\CDROM1
FileSize              : 5550684160
ImagePath             : C:\ISO\Windows\en-us_windows_server_2022_x64_dvd_620d7eac.iso
LogicalSectorSize     : 2048
Number                : 1
Size                  : 5550684160
StorageType           : 1
PSComputerName        :
CimClass              : ROOT/Microsoft/Windows/Storage:MSFT_DiskImage
CimInstanceProperties : {Attached, BlockSize, DevicePath, FileSize…}
CimSystemProperties   : Microsoft.Management.Infrastructure.CimSystemProperties

PS C:\Users\admin>

Expected behavior

($disk | Get-Volume)[0].DriveLetter is available every time.

Actual behavior

($disk | Get-Volume)[0].DriveLetter is null **every third time**.

Error details

No output.

Environment data

PS C:\Users\admin> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      7.4.2
PSEdition                      Core
GitCommitId                    7.4.2
OS                             Microsoft Windows 10.0.19045
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Visuals

No response

@stephen9357 stephen9357 added the Needs-Triage The issue is new and needs to be triaged by a work group. label May 10, 2024
@MartinGC94
Copy link
Contributor

This module is bundled with Windows and is not maintained in this repository. Unfortunately the only way to provide feedback about it is to submit it via the "Feedback hub" app where it will of course be ignored because there's too much garbage for them to sort through.
As for the problem you have, it doesn't happen on my machine so it must be something about your environment. You can work around it by just not using the driveletter and instead use the volume path directly, like this:

PS C:\Users\Martin> $Path = Mount-DiskImage -ImagePath "C:\VMData\Windows 11 23H2.iso" -PassThru -NoDriveLetter | Get-Volume | select -ExpandProperty Path
PS C:\Users\Martin> ls -LiteralPath $Path

        Directory: \\?\Volume{97b6d912-f98f-11ee-8467-d8cb8a18ac3c}\


Mode                LastWriteTime         Length Name
----                -------------         ------ ----
d-r--          01-10-2023   10:29                boot
d-r--          01-10-2023   10:29                efi
d-r--          01-10-2023   10:30                sources
d-r--          01-10-2023   10:30                support
--r--          01-10-2023   10:27          128 B autorun.inf
--r--          01-10-2023   10:27       431.7 KB bootmgr
--r--          01-10-2023   10:27        1.59 MB bootmgr.efi
--r--          01-10-2023   10:27       93.47 KB setup.exe

Most tools support volume paths without any issues and for the ones that don't, you could just copy the files out of the ISO to a temp folder on C:\ or whatever and provide the app with that path instead.

@stephen9357
Copy link
Author

@MartinGC94 Thanks for your reply.
I have tried using the -LiteralPath parameter, but some third-party modules reports error, such as they use Resolve-Path and Test-Path -Path.
Now I call mountvol.exe in my script to assign the drive letter myself, everything works perfectly.
This problem only occurred on two PC, and the drive letter was not assigned strictly every third time. I'm very interested in this problem and want to debug it myself. Do you have any recommendations? For example, where should I look for the log file and what tools can help me?
Thank you again.

@StevenBucher98 StevenBucher98 added the Resolution-External The issue is caused by external component(s). label May 20, 2024
Copy link
Contributor

This issue has been marked as external and has not had any activity for 1 day. It has been be closed for housekeeping purposes.

Copy link
Contributor

microsoft-github-policy-service bot commented May 21, 2024

📣 Hey @stephen9357, how did we do? We would love to hear your feedback with the link below! 🗣️

🔗 https://aka.ms/PSRepoFeedback

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs-Triage The issue is new and needs to be triaged by a work group. Resolution-External The issue is caused by external component(s).
Projects
None yet
Development

No branches or pull requests

3 participants