I'm attempting to put together a .vbs script to get the record count of one of our SQL tables and alert us to either a status of up or down. This was easily accomplished through a powershell script but we lack the license for this in SAM. It works fine when I run it via cmd. But when I attempt to test it against one of the database nodes it throws the error and gives me the output:
Script output values are not defined or improperly defined.
Output: ==============================================
Statistic: Up
What am I missing?
Here is the script:
'declare the variables
Dim Connection
Dim ConnString
Dim Recordset
Dim SQL
'define the connection string, specify database driver
ConnString="DRIVER={SQL Server};SERVER=servername;UID=user;PWD=pass;DATABASE=database"
'declare the SQL statement that will query the database
SQL = "SELECT * FROM batch where currenteventtypeid = 10 and received=2"
'create an instance of the ADO connection and recordset objects
Const adOpenStatic = 3
Const adLockOptimistic = 3
Set Connection = CreateObject("ADODB.Connection")
Set Recordset = CreateObject("ADODB.Recordset")
'Open the connection to the database
Connection.Open ConnString
'Open the recordset object executing the SQL statement and return records
Recordset.Open SQL, Connection, adOpenStatic, adLockOptimistic
If Recordset.RecordCount > 500 Then
Wscript.Echo "Statistic: Down "
Wscript.Quit(1)
Else
Wscript.Echo "Statistic: Up "
Wscript.Quit(0)
End If
'close the connection and recordset objects to free up resources
Recordset.Close
Set Recordset=nothing
Connection.Close
Set Connection=nothing