Failed to load adalsql.dll when calling `Invoke-sqlcmd`

I have VS2015 with SSDT , as well as SSMS and SqlServer PowerShell module (which includes the command invoke-sqlcmd), and yet if I try to execute a query against an Azure SQL data store like this:

invoke-sqlcmd  -Query "Select top 5 * from customer"  -ConnectionString "Server=tcp:my.database.windows.net,1433;Database=Customer;  Authentication=Active Directory Integrated; Encrypt=True; "

I get the following error:

invoke-sqlcmd : Unable to load adalsql.dll (Authentication=ActiveDirectoryIntegrated). Error code: 0x2. For more information, see
http://go.microsoft.com/fwlink/?LinkID=513072
At line:1 char:1
+ invoke-sqlcmd  -Query "Select top 5 * from vwOffer"  -ConnectionStrin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Invoke-Sqlcmd], SqlException
    + FullyQualifiedErrorId : SqlExectionError,Microsoft.SqlServer.Management.PowerShell.GetScriptCommand

invoke-sqlcmd :
At line:1 char:1
+ invoke-sqlcmd  -Query "Select top 5 * from vwOffer"  -ConnectionStrin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Invoke-Sqlcmd], ParserException
    + FullyQualifiedErrorId : ExecutionFailureException,Microsoft.SqlServer.Management.PowerShell.GetScriptComman

If I try to install adalsql.dll , I get a message saying that A higher version already exists, and I can see both versions of the dll can be found here:

 C:\Windows\SysWOW64\adalsql.dll
 C:\Windows\System32\adalsql.dll

and yet, invoke-sqlcmd cannot find it. Any idea how to either (A) register an existing dll so invoke-sqlcmd can find it, or (B) delete it so it can be reinstalled?

, Active Directory Authenticatoin 32- SQLCMD.exe, , 32- dll . 64- dll, ...

+14
4

, . , , , , , , SSMS. :

1) " "

2) sql " Active Directory SQL Server".

3)

4) ADAL ( x64):

https://www.microsoft.com/en-us/download/confirmation.aspx?id=48742

5) ,

6) adalsql.dll!

+25

VS 2019. ADALSQL. "C:\ProgramData\Microsoft\VisualStudio\Packages\sql_adalsql, = 16.0.61903.25110, chip = x64, language = en-US", , .

!

+1

/ " Active Directory". , , , .

, (regedt32)

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer

adalsql.

,

DisplayName: Active Directory Authentication Library for SQL Server
DisplayVersion: 15.0.1300.359

, , . - c:\windows\installer\4c334521.msi. MSI , , "". "", , .

0

, SSMS, " Active Directory SQL Server" SSMS.

The next time you upgrade SSMS, nothing will break. SSMS brings its own adalsql.dll and knows how to update it when updating SSMS. But if you installed adalsql with something else (or using https://www.microsoft.com/en-us/download/confirmation.aspx?id=48742 ), SSMS is somehow broken.

-1
source

All Articles