Skip to content

Instantly share code, notes, and snippets.

@DarkAllien
Last active July 4, 2018 07:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save DarkAllien/555fe66e92e4c2aaace0f706c7aa29f3 to your computer and use it in GitHub Desktop.
Save DarkAllien/555fe66e92e4c2aaace0f706c7aa29f3 to your computer and use it in GitHub Desktop.
<#
************************************************************************************************
This Script used for SQL Version Detection
************************************************************************************************
Created by: Ioan Popovici, 18/03/2015
************************************************************************************************
ModIfied by: Octavian Cordos, 21/03/2018
************************************************************************************************
#>
## Variables for Reference SQL Versions
[System.Version]$SQLVersion = "13.0.4466.4" #2016 KB4057119
Try {
$RegExPattern = "[0-9]+\.[0-9]+\.[0-9]+.[0-9]+"
[System.Version]$GetSQLVersion = (Invoke-Command -ScriptBlock { SQLCMD.exe -Q "Select @@Version" } -ErrorAction Stop | Select-String -Pattern $RegExPattern).Matches.Value
}
Catch {
## Catch Error if SQLCMD is not Found
}
If ($GetSQLVersion.Major -eq $SQLVersion.Major -and $GetSQLVersion -ge $SQLVersion) {
Write-Output "SQL is Updated"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment