Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions Links


SQL Server DBA Jobs

How to master Mount-Diskimage in Powershell

29 June,2020 by Tom Collins

Question: I want to set up a script to Mount a Disk in an automated way utilising Powershell ? The image exists as an ISO on a network path and requires to be made available as a drive letter & path. It doesn't have to be a dedicated drive letter - just the next letter after the highest. So for example , if I already have E:, F:,G:  than I want it to be set as I: . 

I have some code in the script which can identify the drive letter assigned 

Answer: The Powershell code below will create the temporary drive letter and mount the image. 


 %SystemRoot%\system32\WindowsPowerShell\v1.0\powershell.exe  -Command  Mount-DiskImage  -ImagePath  '"\\my_network_path\Microsoft\SQL2017\SW_DVD9_NTRL_SQL_Svr_Ent_Core_2017_64Bit_English_OEM_VL_X21-56995.ISO"'

This is similar as if you were attempting to Mount a disk image ISO  via the manual method.

If you want to dismount the drive - you can either restart the server or alternatively use the Dismount-Image powershell cmdlet. 


PowerShell  -Command  Dismount-DiskImage  -ImagePath  '"\\my_network_path\Microsoft\SQL2017\SW_DVD9_NTRL_SQL_Svr_Ent_Core_2017_64Bit_English_OEM_VL_X21-56995.ISO"'

These sort of techniques can be used in automated procedures - where you could complete repeatable tasks with code. For example if you were building multiple servers - rather than staging the code on the server - you could mount the disk image and install from this point - saving you disk space and keeping the process streamlined

Read more on Powershell and SQL Server install techniques 

Powershell script for unattended install of SQL Server standard patches


Author: Tom Collins (


Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.


Post a comment on How to master Mount-Diskimage in Powershell | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer