1

I'm running the below Powershell

Export-DbaInstance -SqlInstance xxxxxx\xxxxxx -ExcludePassword -Exclude databases -Path \\xxxxx\xxxxx

However, I'm getting the error

'WARNING: [14:34:02][Export-DbaRepServerSetting] Could not load replication libraries | Could not load file or 'Microsoft.SqlServer.Replication.dll' or one of its dependencies. The specified module could not be found.'

It successfully exports everything else except instance replication. I can use the -Exclude 'ReplicationSettings'and Export-DBAInstance works successfully. I can also successfully execute the original script on a Windows 2016 server with any other version of SQL installed.

The Server is Windows 2016 and SQL is 2019 Standard. The file version of the Microsoft.SqlServer.Replication.dll in dbatools smo folder is 2017.140.1000.169 and product version is 14.0.1000.169. The versions in C:\Program Files\Microsoft SQL Server\150\SDK\Assemblies are 2019.150.2000.5 and 15.0.2000.5 respectively.

I have also tried executing Invoke-Expression (Invoke-WebRequest -UseBasicParsing https://dbatools.io/in) to download latest version of dbatools, unblocking the file and importing the dbatools module. I've also tried copying the Microsoft.SqlServer.Replication.dll from a SQL 2016\2012 and 2017 instance into the Assemblies folder above.

Thom A
  • 88,727
  • 11
  • 45
  • 75

2 Answers2

1

The replication functions that were causing the errors in the above command are no longer supported in Dbatools as of 1.0.161. The Microsoft.SqlServer.Rmo.dll that the commands relied upon were usually installed via Sql Server Management Studio (SSMS) 17, and it was implicitly assumed that most users would be using Dbatools from the same box where they used SSMS. SSMS 18 changed the requirements for these dlls, and they could not be loaded and used.

For more details see issues 6897 and 6548 on github.

joshcorr
  • 101
  • 2
  • 10
0

You could try to manually load the assemblies, to check the actual error:

PS> $dbaToolsPath = "xxxx"   # your full path to the dbaTools
PS> $Error.Clear()
PS> Add-Type -Path "$dbaToolsPath\bin\smo\Microsoft.SqlServer.Replication.dll" -ErrorAction Stop
PS> ($Error | Select-Object -Last 1).Exception.InnerException | Select-Object *

And repeat this for the Microsoft.SqlServer.Rmo.dll assembly

mhu
  • 17,720
  • 10
  • 62
  • 93