Fix PowerShell Error: "The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel."
· Ingo Karstein
Just as a reminder.
When getting this error:
The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.
…just add this to your PowerShell script:
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 2 comments
Joe Shu Sep 18, 2022
Got another error:
PS C:\\Windows\\system32> \[Net.ServicePointManager\]::SecurityProtocol = \[Net.SecurityProtocolType\]::Tls12
Cannot set property. Property setting is supported only on core types in this language mode.
At line:1 char:1
\+ \[Net.ServicePointManager\]::SecurityProtocol = \[Net.SecurityProtocolTy ...
\+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\+ CategoryInfo : InvalidOperation: (:) \[\], RuntimeException
\+ FullyQualifiedErrorId : PropertySetterNotSupportedInConstrainedLanguage
ikarstein Sep 18, 2023
Maybe you use PowerShell Core or PowerShell 6 or 7 ?