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
This is only a preview. Your comment has not yet been posted.
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.
Posted by: |