CheckClientUpdates.ps1 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Helper functions to check if TLS 1.2 updates are required
  2. # Script currently supports checking for the following:
  3. # a. Check if SQL Server Native Client can support TLS 1.2
  4. # b. Check if Microsoft ODBC Driver for SQL Server can support TLS 1.2
  5. # This script is restricted to work on x64 and x86 platforms
  6. Function Check-Sqlncli()
  7. {
  8. # Fetch the different Native Client installations found on the machine
  9. $sqlncli = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*Native Client*"} | Select Name,Version
  10. # Check and report if an update is required for each entry found
  11. foreach ($cli in $sqlncli)
  12. {
  13. # SQL Server 2012 and 2014
  14. if ($cli.Version.Split(".")[2] -lt 6538 -and $cli.Version.Split(".")[0] -eq 11)
  15. {
  16. Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
  17. }
  18. # SQL Server 2008
  19. elseif ($cli.Version.Split(".")[2] -lt 6543 -and $cli.Version.Split(".")[1] -eq 0 -and $cli.Version.Split(".")[0] -eq 10)
  20. {
  21. Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
  22. }
  23. # SQL Server 2008 R2
  24. elseif ($cli.Version.Split(".")[2] -lt 6537 -and $cli.Version.Split(".")[1] -eq 50 -and $cli.Version.Split(".")[0] -eq 10)
  25. {
  26. Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
  27. }
  28. else
  29. {
  30. Write-Host $cli.Name "with version" $cli.Version " supports TLS 1.2" -ForegroundColor Green
  31. }
  32. }
  33. }
  34. Function Check-SqlODBC()
  35. {
  36. # Fetch the different MS SQL ODBC installations found on the machine
  37. $sqlodbc = Get-WmiObject -Class Win32_Product | Where-Object {$_.Name -like "*ODBC*"} | Select Name,Version
  38. # Check and report if an update is required for each entry found
  39. foreach ($cli in $sqlodbc)
  40. {
  41. # SQL Server 2012 and 2014
  42. if ($cli.Version.Split(".")[2] -lt 4219 -and $cli.Version.Split(".")[0] -eq 12)
  43. {
  44. Write-Host $cli.Name "with version" $cli.Version " needs to be updated to use TLS 1.2" -ForegroundColor Red
  45. }
  46. else
  47. {
  48. Write-Host $cli.Name "with version" $cli.Version " supports TLS 1.2" -ForegroundColor Green
  49. }
  50. }
  51. }
  52. # Call the functions
  53. Check-Sqlncli
  54. Check-SqlODBC