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.

6 Answers 6


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


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:'}
  • Also failed for me, reason being that $volInfo was empty since Mount-Diskimage didn't put anything in $isomount. Yours seems more reliable. I used -Last 1 since there was already a number of drives from failed attempts. May 14 at 12:53

This is a working version (for me at least)

    $isoImg = "C:\OrdinaDBA\ISO\en_sql_server_2019_developer_x64_dvd_baea4195.iso"
    $driveLetter = "X:\" # note the added ending backslash: mount fails if its not there :(
    #Check if elevated
    [Security.Principal.WindowsPrincipal]$user = [Security.Principal.WindowsIdentity]::GetCurrent();
    $Admin = $user.IsInRole([Security.Principal.WindowsBuiltinRole]::Administrator);
    if ($Admin) 
        Write-Host "Administrator rights detected, continuing install.";
        Write-Host "Mount the ISO, without having a drive letter auto-assigned";
        $diskImg = Mount-DiskImage -ImagePath $isoImg  -NoDriveLetter -PassThru;
        #Write-Host "Get mounted ISO volume";
        $volInfo = $diskImg | Get-Volume
        #Write-Host "Mount volume with specified drive letter";
        mountvol $driveLetter $volInfo.UniqueId
        #Start-Sleep -Seconds 1
        #<do work>
        #Start-Sleep -Seconds 1
        Write-Host "DisMount ISO volume"; 
        DisMount-DiskImage -ImagePath $isoImg  # not used because SQL install is in an other powershell session
        Write-Host "Done";
        exit 0;
        Write-Error "This script must be executed as Administrator.";
        exit 1;

Only started looking at Powershell today when I heard a colleague ask the same question. If it helps, I pieced it together into a 1-liner:

mountvol "Y:" (Mount-DiskImage - ImagePath "c:\x.iso" -NoDriveLetter | Get-Volume).UniqueId

Then to dismount:

Dismount-DiskImage -ImagePath "c:\x.iso"

Best regards

  • I'm not savvy with PS at all, but your one-liner doesn't work for me: I'm mounting a VHDX file, and that part works, but it does not assign a drive letter,"mounvol" acts as though I forgot to pass the VolumeName (which, I assume is the whole point of having the "UniqueId" as part of the line). I keep trying things to no avail... Sep 28 at 22:31
  • I even tried something like this in a PS script and it seems that UniqueId ends up being null for some reason... Frustrating Sep 28 at 22:49

it is also possible to skip accesing via drive letter, like:

$imgDevice = Mount-DiskImage -ImagePath 'C:\SomeIso.iso' -NoDriveLetter -PassThru;
# dir content - do note the added ending backslash:
Get-ChildItem "$($imgDevice.DevicePath)\"

Here you can find all information about Get-DiskImage cmdlet: Get-DiskImage

This command gives you drive letter:

(Get-DiskImage -ImagePath "E:\vhd1.vhdx" | Get-Disk | Get-Partition | Get-Volume).DriveLetter

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .