How to Mount an ISO Image using the Mount-DiskImage PowerShell Cmdlet

Automating Software Installations

In modern Windows environments, installing massive software suites (like Microsoft SQL Server, Exchange Server, or proprietary enterprise applications) often involves downloading a massive .iso image file. While you can easily mount an ISO file by double-clicking it in the Windows File Explorer, doing so across 50 headless servers (Server Core) requires an automated command-line approach.

PowerShell provides a native, incredibly simple cmdlet for this exact scenario: Mount-DiskImage. This command allows you to mount the virtual disk, extract or run the installer silently, and then cleanly unmount the image when finished.

Step 1: Mount the ISO File

Open an elevated PowerShell prompt (Run as Administrator). The syntax requires the absolute file path to the ISO image.

Mount-DiskImage -ImagePath "C:\Downloads\SQLServer2022.iso"

The command will execute silently. The Windows kernel instantly attaches the ISO as a virtual DVD drive and assigns it the next available drive letter (e.g., E:\ or F:\).

Step 2: Retrieve the Assigned Drive Letter

If you are writing an automated installation script, you cannot assume the ISO will always mount to E:\, as other servers might have extra hard drives utilizing that letter. Your script must intelligently discover which drive letter Windows dynamically assigned to the image.

You can pipe the Get-DiskImage command directly into the Get-Volume command to extract this data:

$ISO = Get-DiskImage -ImagePath "C:\Downloads\SQLServer2022.iso" | Get-Volume
$DriveLetter = $ISO.DriveLetter
Write-Host "The ISO is mounted on Drive: $DriveLetter"

You can now use the $DriveLetter variable to execute the setup file directly from the virtual disc:

Start-Process -FilePath "$DriveLetter`:\setup.exe" -ArgumentList "/Q /IACCEPTSQLSERVERLICENSETERMS" -Wait

Step 3: Unmount the ISO

Leaving an ISO mounted indefinitely wastes system resources and can cause backup software (like Veeam) to generate warnings during snapshot creation. Once your installation script is complete, you must explicitly detach the virtual drive.

Use the Dismount-DiskImage cmdlet, passing the exact same file path you used to mount it:

Dismount-DiskImage -ImagePath "C:\Downloads\SQLServer2022.iso"

The virtual DVD drive will instantly vanish from the system, and your automated deployment script will conclude cleanly.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.