≡ Menu

Mount ISO file using Powershell

In this post I will show you how to mount a ISO file using Powershell in Windows Server 2012 and Windows 8 using native cmdlets. I will also explain how to get the drive letter of already mounted ISOs.

We all are aware that ISO files can be mounted as drives in Windows XP/7/8, windows server 2003/2008/2012. While it can be mounted on XP/Windows7 or Windows Server 2003/2008 using third party tools like “Virtual CD/DVD-ROM” from Magic ISO, Windows 8 and Windows Server 2012 provides direct ability to mount ISO files as physical drives. It is not that only ISO can be mounted, we can also mount exisiting VHD files and VHDX(new format of Hyper-V disks) files using the powershell commands in Windows Server 2012 and Windows 8.

I downloaded a Visual Studio ISO for my development requirements and I will show you how to mount that ISO using Powershell. In Windows Server 2012 and Windows 8, there is function called Mount-DiskImage in Storage module that comes by default with the OS installation. This cmdlet can be used to mount the ISO files.

This Mount-DiskImage function takes path of Image file using the -ImagePath argument and type of Image file using -StorageType argument. The -ImagePath argument is mandatory and StorageType argument is optional. When storageType argument is not specified it picks the storage type using the extension of file that you provided.

What I feel missing in this cmdlet is, ability to provide drive letter to which it should be mounted. That will help us easily determine the drive letter without scripts after mounting the ISO file.

Below is the command to mount the ISO file.

Mount-DiskImage -ImagePath c:\local\VS2012_WDX_ENU.iso

This function will not show any output after successful completion, but it will report errors if there are any. Similarly you can pass VHD or VHDX files to mount as physical drives using this function.

If the ISO you are trying to mount is already mounted as physical drive, then you will see error message like below.

Mount-DiskImage : The process cannot access the file because it is being used by another process.At line:1 char:1+ Mount-DiskImage -ImagePath C:\Users\administrator.AD\Downloads\VS2012_WDX_ENU.is …+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~    + CategoryInfo          : NotSpecified: (MSFT_DiskImage …torageType = 1):ROOT/Microsoft/…/MSFT_DiskImage) [Mou   nt-DiskImage], CimException    + FullyQualifiedErrorId : HRESULT 0x80070020,Mount-DiskImage
If you want to know what is the drive letter assigned this ISO file after mounting, you can find it by using below command.

Get-DiskImage -ImagePath c:\local\VS2012_WDX_ENU.iso | Get-Volume

This will display the drive letter and other details as shown in below output.

Hope this article helps and happy learning.