Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

How Mount Disk Image in Powershell

Question:

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 post first appeared on SQLSERVER-DBA.com, please read the originial post: here

Share the post

How Mount Disk Image in Powershell

×

Subscribe to Sqlserver-dba.com

Get updates delivered right to your inbox!

Thank you for your subscription

×