title: Unable to load adalsql.dll error when calling `Invoke-sqlcmd`
body: <p>I have VS2015 with <a href="https://docs.microsoft.com/en-us/sql/ssdt/download-sql-server-data-tools-ssdt" rel="noreferrer">SSDT</a> installed, along with  <a href="https://docs.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms" rel="noreferrer">SSMS</a> and  the <a href="https://www.powershellgallery.com/packages/SqlServer/21.0.17152" rel="noreferrer">SqlServer</a> PowerShell module (which includes the <code>invoke-sqlcmd</code> comand), and yet If I try to execute a query against an Azure SQL Data Warehouse like so:</p>
  
  <pre><code>invoke-sqlcmd  -Query "Select top 5 * from customer"  -ConnectionString "Server=tcp:my.database.windows.net,1433;Database=Customer;  Authentication=Active Directory Integrated; Encrypt=True; "
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>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
  </code></pre>
  
  <p>If I try and install <a href="http://go.microsoft.com/fwlink/?LinkID=513072" rel="noreferrer">adalsql.dll</a> directly, I get a message stating that <code>A higher version already exists</code> and I can see the both versions of the dll can be found here:</p>
  
  <pre><code> C:\Windows\SysWOW64\adalsql.dll
   C:\Windows\System32\adalsql.dll
  </code></pre>
  
  <p>and yet, invoke-sqlcmd cant find it.   Any idea how to either (A) register the existing dll so invoke-sqlcmd can find it or (B) uninstall it so that it can be re-installed?</p>
  
  <p>Incidentally, I <em>am</em> able to use Active Directory Authenticatoin with the 32-bit SQLCMD.exe, so I know the 32 bit dll is working fine.  It's just the 64 bit dll that isn't loading properly...</p>