[Import-DbaCsv] Failure | Unable to load DLL "Microsoft.Data.SqlClient.SNI.x64.dll": The specified module could not be found. (Exception from HRESULT: 0x8007007E)
Verified issue does not already exist?
I have searched and found no existing issue
What error did you receive?
I have a fresh install of dbatools on a Windows Server 2019 environment with SQL Server 2017 and SSMS 19.3.
Steps to Reproduce
Import-DbaCsv -Path "F:\Path\to\a*.csv.gz" -SqlInstance HOSTNAME -Database MyDB -Table TargetTable -Delimiter "|" -WhatIf
Please confirm that you are running the most recent version of dbatools
2.1.30
I've uninstalled dbatools via uninstall-module and reinstalled, error persists
Other details or mentions
This is the first command I've run from dbatools in this environment.
I also ran "Get-DbaDatabase -SqlInstance HOSTNAME" and got the same error about unable to load this DLL.
Initially was running in PowerShell ISE, but also ran under Windows PowerShell.
What PowerShell host was used when producing this error
Windows PowerShell ISE (powershell_ise.exe)
PowerShell Host Version
Name Value
PSVersion 5.1.17763.6893
PSEdition Desktop
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.17763.6893
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
SQL Server Edition and Build number
Microsoft SQL Server 2017 (RTM-CU31-OD) (KB5050533) - 14.0.3490.10 (X64) Feb 19 2025 12:19:28 Copyright (C) 2017 Microsoft Corporation Developer Edition (64-bit) on Windows Server 2019 Datacenter 10.0 <X64> (Build 17763: ) (Hypervisor)
.NET Framework Version
.NET Framework 4.8.4775.0
I've since installed DBATools on 2 other hosts and the above commands work fine. The issue isn't an installation issue, but I have no idea how I would go about troubleshooting it on the original host. Suggestions would be most welcome, as I need dbatools to work on the original host.
I've manually copied the DLL above to C:\Windows\System32 as a workaround to this issue
Microsoft removed SNAC from SQL Server 2022, so this might need further investigation as a dependency issue (/cc @potatoqualitee)
thank you @rwestMSFT. I was MIA for a while there but now i'm back. @KCGL please try with the latest dbatools version. I just updated a whole lot of dependencies and changed the way the library works.
So I have yet another clean WinServer 2019 Standard, with a clean install of SQL2019 Dev. Installed dbatools 2.7.0.
Running Copy-DbaLinkedServer and I get failure | unable to load DLL 'Microsoft.Data.SqlClient.SNI.x64.dll'. The specified module could not be found.
I search the server's C: for the file and it's present in four locations: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\Extensions\Microsoft\SQLDB\DAC C:\Program Files\Microsoft SQL Management Studio 21\Release\Common7\IDE C:\Program Files\WindowsPowerShell\Modules\dbatools.library\2025.8.17\desktop\lib C:\Program Files\KingwaySoft\SSIS Productivity Pack\Unmanaged\64
Same result for Copy-DbaAgentServer, Copy-DbaCredential, Copy-DbaLogin, Copy-Dba-SpConfigure, Copy-DbaDbMail, Copy-DbaInstanceTrigger, Copy-DbaInstanceAudit. Probably others too, but these are the ones I'm using in a script.
While I "can" copy the DLL to a system path... I'm not sure why I should need to since the DLL is evidently in the dbatools.library folder listed above.
@potatoqualitee sorry for the delay in getting back on this.
On this particular server, I'm not able to side-step this problem by copying the SqlClient DLL anywhere that I've tried so far.
Even a very simple command, like:
Show-DbaDbList -SqlInstance MYHOSTNAME
is resulting in the same unable to load DLL error.
Thank you @KCGL. Can you please show me the output of $PSVersionTable and let me know what version of .NET you're on with
Get-ChildItem 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP' -Recurse -ErrorAction Ignore | Get-ItemProperty -Name version -ErrorAction Ignore
should be fixed