Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the drive letter for the ISO I mounted with Mount-DiskImage

Tags:

powershell

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?

like image 241
Justin Dearing Avatar asked May 09 '13 01:05

Justin Dearing


People also ask

How do I create a mountable disk image?

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.

Where is mount ISO?

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.

Can I mount an ISO to a hard 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.

How do I use disk image mounter?

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.


Video Answer


2 Answers

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
like image 101
isaacparrot Avatar answered Sep 25 '22 23:09

isaacparrot


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) 
like image 24
akhil vangala Avatar answered Sep 22 '22 23:09

akhil vangala