0
votes

When I set up an Azure VM (Windows Server 12) I cannot connect from it to an Azure SQL Database because the ODBC driver ("SQL Server") is too old (-> "[Microsoft][ODBC SQL Server Driver][DBNETLIB]SSL Security error"). I hence download & install then the newer driver "ODBC Driver 13 for SQL Server" manually so that the connection works. Fine so far.

Problem: How can I install a new [ODBC] driver on a VM unattended, using a Powershell script, right a after the VM is created?

1

1 Answers

3
votes

This is the PS command to install ODBC 13 on your VM :

$url = "https://download.microsoft.com/download/1/E/7/1E7B1181-3974-4B29-9A47-CC857B271AA2/English/X64/msodbcsql.msi"
$outpath = "c:/odbc.msi"

Invoke-WebRequest -Uri $url -OutFile $outpath

Start-Process -Filepath $outpath -ArgumentList "/qr IACCEPTMSODBCSQLLICENSETERMS=YES"

Save above as a .ps1 file .

Use this command to run command above on your Azure VMs :

$vm = Get-AzVM -Name <VM name> -ResourceGroupName <resource group name>

Invoke-AzVMRunCommand -VM $vm  -CommandId 'RunPowerShellScript' -ScriptPath "<install odbc ps1 file path>"

I have test on my win 2012 vm ,it works for me . Result : enter image description here enter image description here