title: Import-Module SQLServer cannot load file or assembly Microsoft.SqlServer.ConnectionInfo or Microsoft.SqlServer.Smo
body: <p>I have a Powershell script that takes CSV data and loads it into SQL Server but it appears I have some issues connecting to the server, so I'm taking a step back and trying to establish the connection without the rest of the script. My script uses Windows Authentication and when I call 'Import-Module SQLServer', I get the following errors:</p>
  
  <pre><code>PS C:\Users\Student&gt; import-module sqlserver
  add-type : Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo, Version=9.0.242.0, Culture=neutral,
  PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
  At C:\Users\Student\Documents\WindowsPowerShell\Modules\sqlserver\SQLServer.psm1:17 char:8
  + catch {add-type -AssemblyName "Microsoft.SqlServer.ConnectionInfo"}
  +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [Add-Type], FileNotFoundException
      + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.AddTypeCommand
  
  add-type : Could not load file or assembly 'Microsoft.SqlServer.Smo, Version=9.0.242.0, Culture=neutral,
  PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.
  At C:\Users\Student\Documents\WindowsPowerShell\Modules\sqlserver\SQLServer.psm1:20 char:8
  + catch {add-type -AssemblyName "Microsoft.SqlServer.Smo"; $smoVersion  ...
  +        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : NotSpecified: (:) [Add-Type], FileNotFoundException
      + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.AddTypeCommand
  
  WARNING: SMOExtended not available
  
  PS C:\Users\Student&gt; cd SQLSERVER:\SQL
  cd : Cannot find drive. A drive with the name 'SQLSERVER' does not exist.
  At line:1 char:1
  + cd SQLSERVER:\SQL
  + ~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (SQLSERVER:String) [Set-Location], DriveNotFoundException
      + FullyQualifiedErrorId : DriveNotFound,Microsoft.PowerShell.Commands.SetLocationCommand
  </code></pre>
  
  <p>The first two FileNotFoundExceptions only appear the first time I run the Import-Module command, but I still get the ObjectNotFound error from calling Set-Location. What's even more interesting is that I have another functioning version of the script that uses SQL Server authentication to connect to the database through a SqlConnection object instead. When I run this script and then go back and run the Windows Authentication script, I don't get the previous errors and am able to connect to SQL Server without any issues.</p>
  
  <p>I've already tried Reinstalling the SQLServer module and also installing Microsoft.SqlServer.SqlManagementObjects through the .NET CLI as seen at <a href="https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects" rel="nofollow noreferrer">https://www.nuget.org/packages/Microsoft.SqlServer.SqlManagementObjects</a></p>
  
  <p>Also it might be good info to know that both Microsoft.SqlServer.ConnectionInfo.dll and Microsoft.SqlServer.Smo.dll are located at C:\Program Files (x86)\Microsoft SQL Server\120\SDK\Assemblies. Is it possible that they can't be loaded because they aren't in the correct location?</p>
  
  <p>Thanks for any help.</p>
  
  <p>EDIT:</p>
  
  <p>I've discovered that Microsoft.SqlServer.Smo is located at C:\Program Files\Microsoft SQL Server\140\SDK\Assemblies (note Program Files instead of Program Files (x86)) but the ConnectionInfo assembly is not. I'm using SQL Server 2017, and verified that I'm running the x64 version, so I think this could be the issue. Does not having the ConnectionInfo assembly also cause the Smo load failure that I'm getting?</p>