' ********************************************************************* ' ' Name : Verify SQL Server Instance Versions.vbs ' Author : 3Ds (UK) Limited ' Description : Example VBScript to output SQL server version information. ' ' Arguments : None. ' ' Returns : 0 - Success ' 1 - An error occurred. ' ' Notes : Requires Windows Scripting Host (for VBScript). Should ' be called from Sentry-go as an Alert Engine file in ' order to expand the error-specific place-markers. ' ' WIZARD:PARAMS=This script requires no parameters ' WIZARD:PARAMEXAMPLE= ' WIZARD:RESULTS=Return code ...||0 = OK|1 = An error prevented the script from running.||Script output also indicates "OK" for success, or "Error" with details of the faults found. ' ' ********************************************************************* ' Enable in-line error handling On Error Resume Next ' ------ Local declarations ------ Dim objWMI ' WMI object Dim objItem ' WMI item object ' ------ Main Logic ------ Set objWMI = GetObject("WINMGMTS:\\.\root\Microsoft\SqlServer\ComputerManagement") If Err.number <> 0 Then ' Failed to access the details WScript.Echo "Error. Unable to access SQL Server information from WMI. Ensure SQL Server is installed & running on this server. " & Err.Description WScript.Quit (1) End If For Each objItem In objWMI.ExecQuery("Select * From SqlServiceAdvancedProperty WHERE SQLServiceType = 1 AND PropertyName = 'VERSION'") ' Output the information WScript.Echo "OK. SQL Server Instance: " & objItem.ServiceName & ", v" & objItem.PropertyStrValue Next ' ------ Cleanup ------ Set objItem = Nothing Set objWMI = Nothing WScript.Quit (0) ' ------ End of Script ------