Fix PowerShell Error: “The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.”

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 thoughts on “Fix PowerShell Error: “The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.”

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

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.