0

I have an ISO image (in this case an MS Office ISO) that I'd like to mount.

I'd like to use Powershell, and specify the drive letter assignment at the time of mounting, such that I can use scripting commands on files on the mounted ISO (drive), after which time, I'd like to dismount the ISO.

How can this be done?

Background: I'd like to script installation of MS Office given an ISO image.

3

The following Powershell commands will mount the specified ISO image to the specified drive letter. The mountvol command requires elevation, so run Powershell as an Administrator:

# ISO image - replace with path to ISO to be mounted
$isoImg = "D:\en_visio_professional_2019_x86_x64_dvd_3b951cef.iso"
# Drive letter - use desired drive letter
$driveLetter = "Y:"

# Mount the ISO, without having a drive letter auto-assigned
$diskImg = Mount-DiskImage -ImagePath $isoImg  -NoDriveLetter

# Get mounted ISO volume
$volInfo = $diskImg | Get-Volume

# Mount volume with specified drive letter (requires Administrator access)
mountvol $driveLetter $volInfo.UniqueId

#
#
# Do work (e.g. MS Office installation - omitted for brevity)
#
#

# Unmount drive
DisMount-DiskImage -ImagePath $isoImg  

Background: this was a useful reference: https://www.derekseaman.com/2010/04/change-volume-drive-letter-with.html

0

I couldn't get the above to work (Powershell 5 on WS2016), it failed on...

mountvol $driveLetter $volInfo.UniqueId

...Despite being run as Administrator.

But this did work

Get-WmiObject -Class Win32_volume -Filter 'DriveType=5' |
  Select-Object -First 1 |
  Set-WmiInstance -Arguments @{DriveLetter='Z:'}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.