Hi,
I try to make a 3 state monitor with powershell to monitor a SOAP request, where it needs to be critical, when de requeste value (MessageQueueStatus) is wrong, when there is a problem with the monitor (url, …) I need to get a warning (WebserviceStatus).
The powershell works in the ISE, but in SCOM it seems not to be working.
Any ideas?
param([string]$Arguments)
#Test
$Arguments = “https://pvx2cc1n1.ux.pv.be/cc/ws/gw/webservice/cc/MessagingToolsAPI?WSDL;324”
$Parameters = $Arguments.Split(";")
$Wsdl = $Parameters[0]
$MessageQueueID = $Parameters[1]
$WebserviceStatus = “”
$WebserviceEndpoint = “”
$MessageQueueStatus = “”
$ScomAPI = New-Object -comObject “MOM.ScriptAPI”
$PropertyBag = $ScomAPI.CreatePropertyBag()
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
try {
$Webservice = New-WebServiceProxy -Uri $Wsdl
$Authentication = new-Object -TypeName Microsoft.PowerShell.Commands.NewWebserviceProxy.AutogeneratedTypes.WebServiceProxy1vice_cc_MessagingToolsAPI_WSDL.authentication
$Authentication.username = ‘user’
$Authentication.password = ‘password’
$Webservice.authenticationValue = $Authentication
$WebserviceStatus = "OK"
$WebserviceEndpoint = $Webservice.Url
$MessageQueueStatus = $Webservice.getDestinationStatus($MessageQueueID)
}
catch {
$WebserviceStatus = “Not OK”
}
$PropertyBag.AddValue(“WebserviceStatus”,$WebserviceStatus)
$PropertyBag.AddValue(“WebserviceEndpoint”,$WebserviceEndpoint)
$PropertyBag.AddValue(“MessageQueueStatus”,$MessageQueueStatus)
$PropertyBag
#Test
$WebserviceStatus
$WebserviceEndpoint
$MessageQueueStatus
Kind regards,
Luc