We are working on a set of Windows PowerShell 5.1 deployment scripts for a .NET 4.5.2. application. When we uses this script,
Invoke-Sqlcmd -Query "UPDATE SiteContentType set ViewUrl = REPLACE(ViewUrl, 'https:', 'http:'),EditUrl = REPLACE(EditUrl, 'https:', 'http:'),AdminUrl = REPLACE(AdminUrl, 'https:', 'http:'),ViewSecureUrl = REPLACE(ViewSecureUrl, 'https:', 'http:'),ListUrl = REPLACE(ListUrl, 'https:', 'http:')" -Database $articleDatabaseName -ServerInstance $databaseServer -TrustServerCertificate $true -ErrorAction Stop
we get the following error,
Invoke-Sqlcmd : A connection was successfully established with the server, but then an error occurred during the login process.
(provider: SSL Provider, error: 0 – The certificate chain was issued by an authority that is not trusted.)
We have made sure the MS SQL Server 2022 is not using SSL (Force Ecnryption = No
). We have also made sure no certificate is selected for use by the server.
We have also tried adding TrustServerCertificate=True
to the connection string as well as -TrusteServerCertificate $true
to the Invoke-Sqlcmd
in Windows PowerShell
When we connect to the server via the Microsoft SQL Server Manager using the same settings, we connect successfully; no errors.
The website itself also connects successfully. It is only Windows PowerShell that gives this error.
What do we need to do to get a successful connection via Windows PowerShell 5.1?
21