Author Posts

April 7, 2017 at 12:45 pm

Have searched and it seems that it should be possible to set the default values via various regkey's.
But so far none of them have changed the output of:

[Net.ServicePointManager]::SecurityProtocol

So is there a way to include TLS12 as default and not just SSL3 and TLS?

I know you can set this manually in a session.
But I'm wondering if this can be set as a default setting.

April 7, 2017 at 8:41 pm

Try this:

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

It should work against subsequent Invoke-WebRequest calls.

April 7, 2017 at 8:45 pm

Yes but not in the next session without adding it again or e.g. if you're e.g. using DSC.
Via various pages they suggest that you can set the regkeys for schannel, the .netframework hive etc. but nothing seem to affect the defaults of PS.

July 19, 2017 at 10:43 pm

I tried this:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;

and get this:
Cannot convert null to type "System.Net.SecurityProtocolType" due to invalid enumeration values. Specify one o
f the following enumeration values and try again. The possible enumeration values are "Ssl3, Tls"."

I am running Win7 Enterprise SP1, and and have the following installed:
Microsoft .NET Framework 4.6.2 Targeting Pack
Microsoft .NET Framework 4.5.2 Multi-Targeting Pack
Microsoft .NET Framework 4.6.2 Targeting Pack (ENU)
Microsoft .NET Framework 4.6.2
Microsoft .NET Framework 4 Multi-Targeting Pack
Microsoft .NET Framework 4.5 Multi-Targeting Pack
Microsoft .NET Framework 4.5.2 Multi-Targeting Pack (ENU)
Microsoft .NET Framework 4.6.2 SDK
Microsoft .NET Framework 4.5 SDK

I have followed steps getting TLS1.1 and TLS1.2 setup in the registry:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols

All to no avail.

Any ideas welcome!

July 20, 2017 at 6:53 am

You can put

[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12; 

in your Microsoft.PowerShell_profile.ps1 and/or Microsoft.PowerShellISE_profile.ps1.

August 29, 2017 at 9:50 pm

Check out this link: Enabling strong cryptography for all .Net applications

This registry setting worked for me. I had to close PowerShell session and open a new one.
PS > [Net.ServicePointManager]::SecurityProtocol
Tls, Tls11, Tls12

June 6, 2018 at 7:52 am

Please kindly clarify if the line [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 will take effect only per session, and if PS session will be closed (script ends) you will need to use the "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12" every time

June 6, 2018 at 11:39 am

This is what I use to force TLS 1.2

I also have reg entries to disable SSL v3 etc

June 7, 2018 at 2:34 am

It is a per session setting. The cmdlets like Invoke-RestMethod will always by default use, TLS 1.0, so prior to making the call you would have the have the code Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12. While you could mess with the registry, it's probably safer to just force the protocol during the script session.

June 7, 2018 at 3:08 am

Please read this article:
https://johnlouros.com/blog/enabling-strong-cryptography-for-all-dot-net-applications

You need to enable Strong Crypto and then PowerShell will only use TLS 1.0, 1.1, 1.2. But it should try to negotiate as high as it can, meaning it should use 1.2

This does NOT require a server restart; however, you do have to restart your PowerShell session. After that, it will be retained though.

June 7, 2018 at 7:53 am

Thank you for feedback.