powershell-4.0windows-server-2012-r2dbatools

DbaTools Error. How to fix 'Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo' when running Export-DbaInstance


I'm running

Export-DbaInstance -SqlInstance $sourceServerName -Path $absPathToBackupScriptDir

and getting the error 'Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo'

I tried installing Microsoft Visual C++ Redistributable for Visual Studio 2013 and 2017

I tried adding the DLL in question(which IS contained in the DbaTools module) to the GAC using the CMD below

gacutil.exe /i "C:\Program Files\WindowsPowerShell\Modules\dbatools\bin\smo\Microsoft.SqlServer.ConnectionInfo.dll" 

I tried installing the newest version of DbaTools(~0.9.x at time of writing) using the Powershell below

Invoke-Expression (Invoke-WebRequest -UseBasicParsing https://dbatools.io/in) 

Inputted command and complete outputted error message are both below

Export-DbaInstance -SqlInstance $sourceServerName -Path $absPathToBackupScriptDir

'Could not load file or assembly 'Microsoft.SqlServer.ConnectionInfo' Version=14.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91 or one of its dependencies. The system cannot find the file specified.'

Solution

  • If I opt out of exporting replication settings, there is no attempt to load the problematic assembly, and the cmdlet runs as expected.

    Export-DbaInstance -SqlInstance $sourceServerName -Path $absPathToBackupScriptDir -Exclude 'ReplicationSettings'