SQLServerPSModule icon indicating copy to clipboard operation
SQLServerPSModule copied to clipboard

Write-SqlTableData : A parameter cannot be found that matches parameter name 'TrustServerCertificate'

Open GregLeeUpSearch opened this issue 2 years ago • 1 comments

Import-module sqlserver -MinimumVersion 22.2.0

$ConfigInfo = Import-CSV 'C:\ConfigStuffToImportOnSQLServer.txt'

Write-SqlTableData -ServerInstance myinstance -DatabaseName 'master' -SchemaName 'dbo' -TableName 'GoodStuff' -Force -ConnectionTimeout 0 -Timeout 0 -InputData $ConfigInfo -TrustServerCertificate

This command mostly works but out of 200 SQL Servers it fails on 10 of them:

Write-SqlTableData : A parameter cannot be found that matches parameter name 'TrustServerCertificate'.

Additionally Invoke-SqlCmd runs fine against the same instances that fail the above command while using TrustServerCertificate.

The Bug (or I think it is one) is with the version 22.2.0 sqlserver module and Write-SqlTableData.

Thanks, Greg

GregLeeUpSearch avatar Mar 05 '24 17:03 GregLeeUpSearch

Hold on any research here. It started working today. Nothing has changed on my end so I'm waiting to hear from the customer to see if anything changed in their environment surrounding the instances that were previously failing. I will report back in at the beginning of next week.

GregLeeUpSearch avatar Mar 07 '24 19:03 GregLeeUpSearch

Just make sure the new version of the module (currently v22.2.0) is being picked up by the script.

Hi @GregLeeUpSearch,

Older version (21.x and some early v22) did not have the -TrustServerCertificate parameter, hence the possible failure observed.

I'll go ahead and close this issue for now. Just open new one if you see something abnormal. Thanks!

Matteo-T avatar Jun 30 '24 16:06 Matteo-T