Free TLS scripts / Windows
Windows Server post-quantum TLS - free TLS script
Reads the TLS and post-quantum settings of a Windows Server, sets the recommended ones with the hybrid group X25519MLKEM768, and puts everything back on request.
What it does
- Without parameters it only reads: protocols, cipher suites, groups, certificates, overriding Group Policy, .NET strong crypto, roles and last restart, each with a rating, a verdict and the next step.
- With -Apply it sets the Mozilla intermediate profile and post-quantum key exchange for the parts you choose. -WhatIf shows every change and writes nothing.
- Keeps the previous value of everything it changes; -Undo puts back exactly that.
- Refuses a change that a role on the server or your Remote Desktop session depends on, and can roll back by itself after the next restart.
- Restarts Windows only with -Restart, and sends nothing anywhere.
Requires
- Windows Server 2012 R2 or newer with Windows PowerShell 4.0 or 5.1, run as Administrator.
- Post-quantum key exchange needs Windows Server 2025 with update KB5099536. TLS 1.3 needs Windows Server 2022 or 2025. On an older server the script says so and sets what that server has.
- Version
- 1.0
- SHA-256
- fbdf5a3eaaaafb5e4f8817d6a4009c72f9b5a02b12b67c5444d5a41e8edacaf4
- Licence
- Apache License 2.0, copyright FairSSL A/S. Use it, change it and share it, also commercially.
Download the file. Run it in PowerShell as Administrator.
Commands
.\Set-WindowsServerTls.ps1 | Read the server. Nothing is changed. |
|---|---|
.\Set-WindowsServerTls.ps1 -Apply -WhatIf | See what the recommended settings would change. |
.\Set-WindowsServerTls.ps1 -Apply -AutoRollbackMinutes 30 | Set them, with an automatic rollback 30 minutes after the next restart. |
.\Set-WindowsServerTls.ps1 -KeepChanges | Restart Windows when it suits you, log in again and keep the settings. |
.\Set-WindowsServerTls.ps1 -Report Html -ReportPath C:\Temp\tls-report.html | Writes the report as HTML or JSON to a file. |
.\Set-WindowsServerTls.ps1 -Apply -Parts PqcGroups | Switches on post-quantum key exchange only, and leaves protocols and cipher suites alone. |
.\Set-WindowsServerTls.ps1 -Apply -Pqc Ignore | Sets protocols and cipher suites and leaves the groups alone. |
.\Set-WindowsServerTls.ps1 -Apply -Parts Protocols,Ciphers,PqcGroups,Client,DotNet | Also sets the client side and .NET strong crypto. |
.\Set-WindowsServerTls.ps1 -Apply -Pqc Only -AutoRollbackMinutes 30 | Accepts only TLS 1.3 with a post-quantum hybrid group. Clients without one can no longer connect. |
.\Set-WindowsServerTls.ps1 -Undo | Puts back everything the script changed. |
How it decides (details)
The script reads and writes Windows Schannel, which every service on the server uses for TLS: IIS, Exchange, Remote Desktop, SQL Server, AD FS, LDAPS and WinRM over HTTPS. It uses the same code as the sslbrain agent for Windows, so the script and sslbrain give the same answer on the same server.
Reading (no parameters). Nothing is written, and it runs without administrator rights, with less detail. The verdict for each item is one of:
- OK: already active
- APPLY: the script can set it; the line gives the command
- GROUP POLICY: a Group Policy sets the cipher-suite or curve order, which Windows uses instead of the local one; the line gives the value to put in the policy
- UPDATE: install the update named (KB5099536 for post-quantum key exchange on Server 2025)
- UPGRADE: this Windows version cannot: Server 2012 R2, 2016 and 2019 have no TLS 1.3, Server 2022 has no post-quantum key exchange
- RESTART: written after the last restart; Windows uses it from the next one
The rating. The report also rates every protocol, cipher suite and group, and the key and the signature hash of each certificate Windows binds to a port itself (HTTP.sys, which IIS, WinRM over HTTPS, AD FS and Web Application Proxy use, and Remote Desktop), with one of four levels:
- Use: TLS 1.3; the hybrid groups X25519MLKEM768, SecP256r1MLKEM768 and SecP384r1MLKEM1024; AES-256-GCM; a certificate key of RSA 3072 or larger or ECC P-384; SHA-256 and SHA-384
- Works in a transition: TLS 1.2 with ECDHE and an AEAD cipher, so no cipher suite of TLS 1.2 is rated higher; the curves P-384 and P-521; AES-128-GCM and ChaCha20-Poly1305; an RSA 2048 key, for old equipment only
- Remove now (our interpretation)*: X25519 or P-256 alone, DHE, CBC cipher suites, ECC P-256 and Ed25519 keys
- Removal recommended long ago: SSL 2.0, SSL 3.0, TLS 1.0 and TLS 1.1; RSA key transport, static DH; RC4, 3DES, NULL, EXPORT and anonymous suites; RSA 1024 and smaller; SHA-1 and MD5
* May be broken. The list is sslbrain's of 4 December 2026, after NSA's "Immediate Actions to Push Toward Post-Quantum" (2 December 2026) and Mozilla's TLS guidelines; "Remove now" is our interpretation of NSA's text. The recommended level keeps X25519 and P-256 after the hybrid group, for clients without post-quantum key exchange, so the report says Remove now for them there too; -Pqc Only leaves only the hybrid groups.
The profile (-Apply) is Mozilla's intermediate configuration, version 6.0:
- Protocols: SSL 2.0, SSL 3.0, TLS 1.0 and TLS 1.1 off, TLS 1.2 on, TLS 1.3 on where Windows has it
- Cipher suites: TLS_AES_128_GCM_SHA256, TLS_AES_256_GCM_SHA384, TLS_CHACHA20_POLY1305_SHA256, and for TLS 1.2 the ECDHE suites with AES-GCM and ChaCha20-Poly1305
- Groups: X25519_MLKEM768 first; the groups already on the server stay as fallback
-Pqc chooses the level of post-quantum key exchange:
- Ignore: the groups are not touched
- WhenPossible: X25519_MLKEM768 is put first where the server can; elsewhere the report says why not
- Only: TLS 1.3 only, and only the three hybrid groups of RFC 10024 (X25519MLKEM768, SecP256r1MLKEM768, SecP384r1MLKEM1024). A server that cannot is not changed. The group list also applies to the connections the server itself makes.
-Parts chooses what is written: Protocols (the Server keys), Ciphers, PqcGroups, Client (the same protocols for the connections the server makes) and DotNet (SchUseStrongCrypto and SystemDefaultTlsVersions for .NET Framework 2 and 4, 32 and 64 bit). Without -Parts it is Protocols, Ciphers and PqcGroups.
Windows Server 2012 R2 has no TLS cmdlets and no ECDHE suite with AES-GCM for an RSA certificate, so there the script sets the protocols and reports the cipher-suite order without changing it. Where a Group Policy sets the cipher-suite order or the curve order, the script leaves that part alone and the report gives the value for the policy.
What it refuses, until you add -Force:
- switching TLS 1.0 and 1.1 off on a server with SQL Server 2014 or older, or from a Remote Desktop client older than Windows 8. The cipher suites then stay as they are too: TLS 1.0 and 1.1 have none of the profile's;
- changing the cipher suites from a Remote Desktop client older than Windows 8.1, which has none of the profile's suites for an RSA certificate;
- changing the groups on a server with Exchange, where Microsoft documents its own curve order;
- -Pqc Only on a server with Exchange, SQL Server, AD FS, Web Application Proxy, Remote Desktop Services or Active Directory Domain Services, or with Remote Desktop switched on;
- switching TLS 1.0 and 1.1 off, and changing the cipher suites, on a server with Exchange or AD FS before .NET strong crypto is set (add DotNet to -Parts and they are set together).
Each refusal names the role and the reason, and the other parts are still set. -Pqc Only is set as a whole or not at all: it needs the parts Protocols and PqcGroups and no Group Policy curve order.
Undo. Before the first change the script starts a journal in C:\ProgramData\sslbrain-tls (Administrators and SYSTEM only). For every item it changes, the journal keeps the value from before the script's first change, with its registry type and whether it existed, or the full order of the cipher suites or groups, and what the script wrote. -Undo puts each item back when it still holds what the script wrote. An item an administrator has changed since is left alone and named; -Undo -Force puts it back too. Keys the script created are removed when they are empty. Run again, -Undo has nothing left to do. -Undo -WhatIf lists what would be put back.
Automatic rollback. -AutoRollbackMinutes registers the scheduled task "sslbrain-tls rollback", which runs as SYSTEM after each start of Windows, the given number of minutes after the start. If you have run -KeepChanges by then, nothing happens. If you have not, because you can no longer log in, the task puts back what that -Apply changed, restarts Windows once so the previous settings are active, and removes itself. -KeepChanges and -Undo remove the task. While it is armed a new -Apply is refused: keep or undo the first one, then apply again.
Restart. A service may use a changed group or protocol for new connections at once; all of Windows uses the changes from its next restart. The script restarts only with -Restart, 60 seconds after it has finished (shutdown /a cancels it), and when the automatic rollback you armed has put settings back. The automatic rollback counts from a start of Windows, so if contact is lost before the restart, restart the server from its console or hypervisor.
Exit codes:
- 0: done, or nothing to do
- 1: failed; what this run had written is put back
- 2: a part was refused (see above); the other parts are done
- 3: not run as Administrator, or not a supported Windows
Parameters
| -Apply | Sets the recommended profile for the parts in -Parts, at the level in -Pqc. |
|---|---|
| -Undo | Puts back everything the script has changed on this server. |
| -KeepChanges | Cancels the automatic rollback: the settings stay. |
| -Pqc | Post-quantum key exchange: Ignore, WhenPossible (default) or Only. |
| -Parts | What -Apply writes: Protocols, Ciphers, PqcGroups, Client, DotNet. Default: Protocols, Ciphers, PqcGroups. |
| -Report | The report's format: Text (default), Json or Html. |
| -ReportPath | Writes the report to this file instead of the screen. |
| -AutoRollbackMinutes | With -Apply: undo and restart this many minutes after the next start of Windows, unless -KeepChanges was run. |
| -Restart | Restarts Windows 60 seconds after a run that wrote something. |
| -Force | Sets a part the script would refuse, and with -Undo also puts back what an administrator changed afterwards. |
| -RollbackTask | Used by the scheduled task the script registers for the automatic rollback. |
Writing a guide or answering a question? Link to this page instead of copying the script: it always has the newest version and its SHA-256.
[Windows Server post-quantum TLS - free TLS script](https://sslbrain.com/free-tls-scripts/windows-server-post-quantum-tls/) <a href="https://sslbrain.com/free-tls-scripts/windows-server-post-quantum-tls/">Windows Server post-quantum TLS - free TLS script</a> One script per server, or sslbrain does it for all your servers without scripts.
Feedback and improvements are welcome: info@fairssl.dk