[CmdletBinding(SupportsShouldProcess = $true)] param([switch]$Apply) $ErrorActionPreference = 'Stop' if (-not $IsWindows -and $PSVersionTable.PSEdition -eq 'Core') { throw 'This script must run on the Windows TLS termination server.' } if (-not (Get-Command Get-TlsCipherSuite -ErrorAction SilentlyContinue) -or -not (Get-Command Disable-TlsCipherSuite -ErrorAction SilentlyContinue)) { throw 'Windows TLS cipher suite cmdlets are unavailable on this server.' } $availableSuites = Get-TlsCipherSuite $cbcSuites = @($availableSuites | Where-Object { $_.Name -match '_CBC_' } | ForEach-Object { $_.Name }) $modernSuites = @($availableSuites | Where-Object { $_.Name -match '_GCM_|_CHACHA20_' }) if ($modernSuites.Count -eq 0) { throw 'No modern TLS cipher suite was found; no changes were made.' } Write-Host "CBC suites to disable: $($cbcSuites.Count)" Write-Host 'TLS 1.0 and TLS 1.1 server protocols to disable.' if (-not $Apply) { Write-Host 'Preview only. Run with -Apply on the Windows TLS termination server after a maintenance window is approved.' return } $principal = New-Object Security.Principal.WindowsPrincipal([Security.Principal.WindowsIdentity]::GetCurrent()) if (-not $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)) { throw 'Administrator privileges are required.' } foreach ($version in @('TLS 1.0', 'TLS 1.1')) { $path = "HKLM:\SYSTEM\CurrentControlSet\Control\SecurityProviders\SCHANNEL\Protocols\$version\Server" if ($PSCmdlet.ShouldProcess($path, 'Disable server protocol')) { New-Item -Path $path -Force | Out-Null New-ItemProperty -Path $path -Name Enabled -PropertyType DWord -Value 0 -Force | Out-Null New-ItemProperty -Path $path -Name DisabledByDefault -PropertyType DWord -Value 1 -Force | Out-Null } } foreach ($suite in $cbcSuites) { if ($PSCmdlet.ShouldProcess($suite, 'Disable TLS cipher suite')) { Disable-TlsCipherSuite -Name $suite } } Write-Host 'TLS changes were applied. Restart the TLS termination service or server as appropriate, then run an external scan.'