Repository: microsoft/CSS-Exchange
File: Diagnostics/HealthChecker/Analyzer/Security/Invoke-AnalyzerSecuritySettings.ps1 (PowerShell)

Code before:
            }
        }
    }

    foreach ($tlsKey in $tlsVersions) {
        $currentTlsVersion = $osInformation.TLSSettings.Registry.TLS[$tlsKey]
        $outputObjectDisplayValue = New-Object System.Collections.Generic.List[object]
        $outputObjectDisplayValue.Add((NewDisplayObject "Enabled" -Location $currentTlsVersion.ServerRegistryPath -Value $currentTlsVersion.ServerEnabledValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "DisabledByDefault" -Location $currentTlsVersion.ServerRegistryPath -Value $currentTlsVersion.ServerDisabledByDefaultValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "Enabled" -Location $currentTlsVersion.ClientRegistryPath -Value $currentTlsVersion.ClientEnabledValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "DisabledByDefault" -Location $currentTlsVersion.ClientRegistryPath -Value $currentTlsVersion.ClientDisabledByDefaultValue))
        $displayWriteType = "Green"

        # Any TLS version is Misconfigured or Half Disabled is Red
        # Only TLS 1.2 being Disabled is Red
        # Currently TLS 1.3 being Enabled is Red
        # TLS 1.0 or 1.1 being Enabled is Yellow as we recommend to disable this weak protocol versions
        if (($currentTlsVersion.TLSConfiguration -eq "Misconfigured" -or
                $currentTlsVersion.TLSConfiguration -eq "Half Disabled") -or
                ($tlsKey -eq "1.2" -and $currentTlsVersion.TLSConfiguration -eq "Disabled") -or
                ($tlsKey -eq "1.3" -and $currentTlsVersion.TLSConfiguration -eq "Enabled")) {
            $displayWriteType = "Red"
        } elseif ((($tlsKey -eq "1.0") -and
            ($currentTlsVersion.TLSConfiguration -eq "Enabled")) -or
            (($tlsKey -eq "1.1") -and
            ($currentTlsVersion.TLSConfiguration -eq "Enabled"))) {
            $displayWriteType = "Yellow"
        }

        $params = $baseParams + @{
            Name             = "TLS $tlsKey"
            Details          = $currentTlsVersion.TLSConfiguration
            DisplayWriteType = $displayWriteType
        }
        Add-AnalyzedResultInformation @params

        $params = $baseParams + @{
            OutColumns           = ([PSCustomObject]@{
                    DisplayObject      = $outputObjectDisplayValue
                    ColorizerFunctions = @($sbValue)
                    IndentSpaces       = 8
                })
            OutColumnsColorTests = @($sbValue)
            HtmlName             = "TLS Settings $tlsKey"
            TestingName          = "TLS Settings Group $tlsKey"
        }
        Add-AnalyzedResultInformation @params
    }

    $netVersions = @("NETv4", "NETv2")
    $outputObjectDisplayValue = New-Object System.Collections.Generic.List[object]

Review comment (suggestion):
```suggestion
        } elseif ($currentTlsVersion.TLSConfiguration -eq "Enabled" -and
            ($tlsKey -eq "1.1" -or $tlsKey -eq "1.0")) {
```
This `if` statement can be simplified. 

Code after:
            }
        }
    }

    foreach ($tlsKey in $tlsVersions) {
        $currentTlsVersion = $osInformation.TLSSettings.Registry.TLS[$tlsKey]
        $outputObjectDisplayValue = New-Object System.Collections.Generic.List[object]
        $outputObjectDisplayValue.Add((NewDisplayObject "Enabled" -Location $currentTlsVersion.ServerRegistryPath -Value $currentTlsVersion.ServerEnabledValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "DisabledByDefault" -Location $currentTlsVersion.ServerRegistryPath -Value $currentTlsVersion.ServerDisabledByDefaultValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "Enabled" -Location $currentTlsVersion.ClientRegistryPath -Value $currentTlsVersion.ClientEnabledValue))
        $outputObjectDisplayValue.Add((NewDisplayObject "DisabledByDefault" -Location $currentTlsVersion.ClientRegistryPath -Value $currentTlsVersion.ClientDisabledByDefaultValue))
        $displayWriteType = "Green"

        # Any TLS version is Misconfigured or Half Disabled is Red
        # Only TLS 1.2 being Disabled is Red
        # Currently TLS 1.3 being Enabled is Red
        # TLS 1.0 or 1.1 being Enabled is Yellow as we recommend to disable this weak protocol versions
        if (($currentTlsVersion.TLSConfiguration -eq "Misconfigured" -or
                $currentTlsVersion.TLSConfiguration -eq "Half Disabled") -or
                ($tlsKey -eq "1.2" -and $currentTlsVersion.TLSConfiguration -eq "Disabled") -or
                ($tlsKey -eq "1.3" -and $currentTlsVersion.TLSConfiguration -eq "Enabled")) {
            $displayWriteType = "Red"
        } elseif ($currentTlsVersion.TLSConfiguration -eq "Enabled" -and
            ($tlsKey -eq "1.1" -or $tlsKey -eq "1.0")) {
            $displayWriteType = "Yellow"
        }

        $params = $baseParams + @{
            Name             = "TLS $tlsKey"
            Details          = $currentTlsVersion.TLSConfiguration
            DisplayWriteType = $displayWriteType
        }
        Add-AnalyzedResultInformation @params

        $params = $baseParams + @{
            OutColumns           = ([PSCustomObject]@{
                    DisplayObject      = $outputObjectDisplayValue
                    ColorizerFunctions = @($sbValue)
                    IndentSpaces       = 8
                })
            OutColumnsColorTests = @($sbValue)
            HtmlName             = "TLS Settings $tlsKey"
            TestingName          = "TLS Settings Group $tlsKey"
        }
        Add-AnalyzedResultInformation @params
    }

    $netVersions = @("NETv4", "NETv2")
    $outputObjectDisplayValue = New-Object System.Collections.Generic.List[object]

    $sbValue = {