05 May,2018 by Tom Collins
Question: I'm trying build some Powershell scripts to automate and standardize the SQL Server patching process. One of the steps is to create a temporary drive with a dedicated letter . This drive should be mapped to a network share. That way the executable , which exists on the network , will run as if on the local server.
How can I create the new drive , mapped to a network share in Powershell?
Answer: Powershell has a few different cmdlets for this purpose. I like using New-PSDrive . The New-PSDRive allows you to nominate a drive letter , point to a network share and persist.
This is an example of how to apply New-PSDrive . In this case , I'm creating a new drive "S" - mapped to the network share.
New-PSDrive -Name "S" -Root '"\\mmynetworkshare\data\SQL KB4058561_SQL_Server_2016_SP1_CU"' -Persist -PSProvider "FileSystem"
If you're interested in more Powershell scripts check Powershell scripts for DBA
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: |