In our previous tip we showed how you can easily turn local folders into ISO file images. Today, we look at how you can mount (and dismount) your own and any other ISO files so they can be used just like a local file system drive.
Mounting ISO files is simple:
# make sure you adjust this path so it points to an # existing ISO file: $Path = "$env:temp\myImageFile.iso" $result = Mount-DiskImage -ImagePath $Path -PassThru $result
Immediately after you execute this code, a new CDROM drive appears in Windows Explorer and can be used like any other drive. ISO image-based drives are strictly read-only, of course, as they behave just like a regular CD ROM.
While Mount-DiskImage mounts the ISO image just fine, it will not return the assigned drive letter to you. If you wanted to access the contents of the ISO image from within your script, here is how you find out its assigned drive letter:
# make sure you adjust this path so it points to an # existing ISO file: $Path = "$env:temp\myImageFile.iso" $result = Mount-DiskImage -ImagePath $Path -PassThru $result $volume = $result | Get-Volume $letter = $volume.Driveletter + ":\" explorer $letter
To dismount the drive after use, run Dismount-DiskImage and specify the path to your ISO file that you mounted before:
Dismount-DiskImage -ImagePath $Path