How can I check whether TLS 1.2 is enabled in the browser (not in registry) using a PowerShell script?
-
you'll need to figure out the respective registry key for that browser setting. Unfortunately I suspect that may be a per user setting which makes things a lot trickier. While you can check reg keys in HKCU it will be your registry and HKU will be populated with only users that are logged in. It just makes things quite complicated but not impossible.mOjO– mOjO2021-10-01 17:28:14 +00:00Commented Oct 1, 2021 at 17:28
-
Did you intend to add the PowerShell 4 tag? If so, TLS 1.2 is unsupported in PowerShell 4 because PS v4 uses .NET 4.0, which doesn't support TLS 1.2.TylerH– TylerH2024-06-04 13:25:39 +00:00Commented Jun 4, 2024 at 13:25
2 Answers
When running in the PowerShell_ISE, the .Net Class Property is a simple method to query TLS settings:
[Net.ServicePointManager]::SecurityProtocol
If TLS is only enabled the output will be:
Ssl, Tls
If TLS1.2 is enabled then the list will be:
Tls, Tls11, Tls12
However, the return type is a System.Enum, which can be checked using a regular expression as follows:
[Net.ServicePointManager]::SecurityProtocol -match "Tls12"
Resulting in a boolean result
1 Comment
To check the schannel keys in your question, this works
$key = 'HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\TLS 1.2\Client\'
if (Test-Path $key) {
$TLS12 = Get-ItemProperty $key
if ($TLS12.DisabledByDefault -ne 0 -or $TLS12.Enabled -eq 0) {
Throw "TLS 1.2 Not Enabled"
}
}
Note that most browsers also check the SecureProtocols value in Internet Settings, which can be set per-user or for the whole machine:
# User settings
Get-ItemProperty 'hkcu:\Software\Microsoft\Windows\CurrentVersion\Internet Settings' -Name SecureProtocols
# Machine settings
Get-ItemProperty 'hklm:\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings' -Name SecureProtocols
The Value is a little strange since it is a combination of the hex-values for each supported protocol. For example, TLS1.2 is 0x800 or 2048. Check out the Microsoft TLS 1.2 page for more details on all this information.
It is showing 280 tls 1.2 off,tls 1.2 a80 On in my laptop registry.
6 Comments
0or1. Please check out the linked page for more information.if (Test-Path $key) is false, there is no error output