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

Greg Lee 0 Reputation points
2024-03-05T16:39:18.87+00:00

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'.

Windows for business | Windows Server | User experience | PowerShell
SQL Server | Other
SQL Server | Other

Additional SQL Server features and topics not covered by specific categories

Locked Question. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

2 answers

Sort by: Most helpful
  1. Randy Kroeger 0 Reputation points
    2026-11-11T18:14:54.94+00:00

    I ended up just installing SqlServer module again with using the force and it solved the problem. I was using an older version of SqlServer and you need to use v22.

    Find versions in Powershell (as admin): Get-Module SqlServer -ListAvailable

    Install latest: Install-Module -Name SqlServer -Force

    Was this answer helpful?

    0 comments No comments
  2. Olaf Helper 47,631 Reputation points
    2024-03-05T18:56:59.5033333+00:00

    out of 200 SQL Servers it fails on 10 of them:

    Have all 200 SQL Server the same version or do the 10 have a different one?

    Sorry, you provided so less informations, it's difficult to guess.

    Was this answer helpful?