Posts

Showing posts with the label SCOM

how to execute query from VBScript in script two state monitor SCOM

here is code : 'define and create objects for passing values in 2 state to SCOM Dim oAPI, oBag Set oAPI = CreateObject("MOM.ScriptAPI") Set oBag = oAPI.CreatePropertyBag() StrConnect = "PROVIDER=SQLOLEDB.1;Integrated Security=SSPI;INITIAL CATALOG=DBName;DATA SOURCE=ServerName" Set cnt = CreateObject("ADODB.Connection") cnt.Open StrConnect set recordSet = CreateObject("ADODB.Recordset") SQLStr = " select * from .... " recordSet.Open SQLStr, cnt,1,1 TotalRecords = recordSet.RecordCount recordSet.Close : set recordSet = nothing cnt.Close : set cnt = nothing 'We have to handle Status value from SCOM and create rule for each state If TotalRecords >= 0 Then Call oBag.AddValue("Status","ERROR") Else Call oBag.AddValue("Status","OK") End If Call oAPI.Return(oBag)