mirror of
https://github.com/Microsoft/sql-server-samples.git
synced 2025-12-08 14:58:54 +00:00
PowerShell script for identifying the TLS 1.2 SQL Server client/server updates required for SQL Server.
57 lines
2.4 KiB
PowerShell
57 lines
2.4 KiB
PowerShell
# Helper functions to check if TLS 1.2 updates are required
|
|
# Script currently supports checking for the following:
|
|
# a. Check if SQL Server Native Client can support TLS 1.2
|
|
# b. Check if Microsoft ODBC Driver for SQL Server can support TLS 1.2
|
|
# This script is restricted to work on x64 and x86 platforms
|
|
Function Check-Sqlncli()
|
|
{
|
|
# Fetch the different Native Client installations found on the machine
|
|
$sqlncli = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*Native Client*"} | Select Name,Version
|
|
# Check and report if an update is required for each entry found
|
|
foreach ($cli in $sqlncli)
|
|
{
|
|
# SQL Server 2012 and 2014
|
|
if ($cli.Version.Split(".")[2] -lt 6538 -and $cli.Version.Split(".")[0] -eq 11)
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
|
|
}
|
|
# SQL Server 2008
|
|
elseif ($cli.Version.Split(".")[2] -lt 6543 -and $cli.Version.Split(".")[1] -eq 0 -and $cli.Version.Split(".")[0] -eq 10)
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
|
|
}
|
|
# SQL Server 2008 R2
|
|
elseif ($cli.Version.Split(".")[2] -lt 6537 -and $cli.Version.Split(".")[1] -eq 50 -and $cli.Version.Split(".")[0] -eq 10)
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
|
|
}
|
|
else
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " supports TLS 1.2" -ForegroundColor Green
|
|
}
|
|
}
|
|
}
|
|
|
|
Function Check-SqlODBC()
|
|
{
|
|
# Fetch the different MS SQL ODBC installations found on the machine
|
|
$sqlodbc = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*ODBC*"} | Select Name,Version
|
|
# Check and report if an update is required for each entry found
|
|
foreach ($cli in $sqlodbc)
|
|
{
|
|
# SQL Server 2012 and 2014
|
|
if ($cli.Version.Split(".")[2] -lt 4219 -and $cli.Version.Split(".")[0] -eq 12)
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
|
|
}
|
|
else
|
|
{
|
|
Write-Host $cli.Name "with version" $cli.Version " supports TLS 1.2" -ForegroundColor Green
|
|
}
|
|
}
|
|
}
|
|
|
|
# Call the functions
|
|
Check-Sqlncli
|
|
Check-SqlODBC
|