I have an ISO I mount via the Mount-DiskImage command. However, I don't know how to get the drive letter for the mounted disk Image. I try $mountResult = Mount-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso -PassThru
. None of the information that is returned is the drive letter as illustrated below:
PS C:\Windows\system32> $mountResult | fl * Attached : False BlockSize : 0 DevicePath : FileSize : 110100480 ImagePath : D:\ISOs\clonezilla-live-1.2.12-10-i486.iso LogicalSectorSize : 2048 Number : Size : 110100480 StorageType : 1 PSComputerName : CimClass : ROOT/Microsoft/Windows/Storage:MSFT_DiskImage CimInstanceProperties : {Attached, BlockSize, DevicePath, FileSize...} CimSystemProperties : Microsoft.Management.Infrastructure.CimSystemProperties PS C:\Windows\system32> $mountResult | select -ExpandProperty CimSystemProperties | fl * Namespace : ROOT/Microsoft/Windows/Storage ServerName : ECHO-BASE ClassName : MSFT_DiskImage Path :
Calling Get-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso
after doesn't return the drive letter either.
How do I get the drive letter?
Press Command+Space, type Disk Utility, and press Enter to open it. Click the “File” menu, select “Open Image,” and select the disc image you want to mount.
Open "My Computer", and navigate to the folder containing the iso file. Right-click on the iso file, the shell context menu will popup. Select "Mount image to drive ..." from the shell context menu. The selected iso file will be mounted to the virtual drive.
An ISO image can be burned to a CD/DVD. It can be mounted to any directory in the hard disk. It can be burned to a CD, and then the contents be copied to the hard disk.
Locate the ISO file that you want to mount, and right-click on it. In the context menu, click on the “Open With Disk Image Mounter” option. Once the image is mounted, a device icon should appear on the desktop. Double-click on it and the Gnome file manager will open up.
Try this:
$mountResult = Mount-DiskImage D:\ISOs\clonezilla-live-1.2.12-10-i486.iso -PassThru $mountResult | Get-Volume
This will return which drive letter that ISO is assigned to along with other info -- from there it's just a matter of parsing the output.
EDIT: This will return JUST the drive letter:
$driveLetter = ($mountResult | Get-Volume).DriveLetter
FYI I had an issue mounting same image again so I made a small change, which checks if image is already mounted if not mounts and give the volume.
$ImagePath= " " ## Path of ISO image to be mounted $ISODrive = (Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter IF (!$ISODrive) { Mount-DiskImage -ImagePath $ImagePath -StorageType ISO } $ISODrive = (Get-DiskImage -ImagePath $ImagePath | Get-Volume).DriveLetter Write-Host ("ISO Drive is " + $ISODrive)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With