Hi,
Our main probe is running in domain1.local, a second probe is running in domain2.local We monitor a webserver in domain2 with the probe in domain2., this works OK. I want to add an XML/EXE sensor to that for a specific query on the webserver. Afaik I've configured all OK; the Powershell script is providing output, however not completely.
Script:
param( [string] $Server ) $Webrequest=Invoke-Webrequest "http://$Server/axwebservice/OnlineItemInfo.aspx?authid=Axweb2014_!&custaccount=1234567&extcodecode=AWS_Izi&Articles=BDA671;017;30;1&hidenetprice=false" if ($($Webrequest.StatusCode) -eq "200") { $result = 0 } else { $result = 1 } $xmlOutput = '<?xml version="1.0" encoding="UTF-8" ?><prtg>' #$xmlOutput = $xmlOutput + "<result><channel>AX-webserverState</channel><value>$result</value><LimitMaxError>1</LimitMaxError><LimitMode>1</LimitMode><Unit>Count</Unit></result>" $xmlOutput = $xmlOutput + "<result><channel>AX-webserverState</channel><value>$result</value><LimitMaxError>1</LimitMaxError></result>" $xmlOutput = $xmlOutput + "</prtg>" $xmlOutput $server | Out-File -encoding utf8 "c:\temp\$server.xml" Invoke-Webrequest "http://$Server/axwebservice/OnlineItemInfo.aspx?authid=Axweb2014_!&custaccount=1234567&extcodecode=AWS_Izi&Articles=BDA671;017;30;1&hidenetprice=false" | Out-File -encoding utf8 "c:\temp\$server.xml" -append $xmlOutput | Out-File -encoding utf8 "c:\temp\$server.xml" -append
When starting the script from prtg (Scan Now), I get the following output:
WSAX17.domain2.local <?xml version="1.0" encoding="UTF-8" ?><prtg><result><channel>AX-webserverState</channel><value>1</value><LimitMaxError>1</LimitMaxError></result></prtg>
The value is 1 but not OK; it should be 0
Starting the script with parameter WSAX17.domain2.local from the PS prompt I get the expected output: WSAX17.domain2.local
StatusCode : 200 StatusDescription : OK Content : <OnlineItemInfoResponse> <Header> <ticket></ticket> </Header> <Article> <resultcode>0</resultcode> <resulttext></resulttext> <articlenr>BDA671;017;30;1</articlenr> <i... RawContent : HTTP/1.1 200 OK Pragma: no-cache Content-Length: 1014 Cache-Control: no-cache Content-Type: text/xml; charset=utf-8 Date: Fri, 13 Jan 2023 09:39:48 GMT Expires: -1 Server: Microsoft-IIS/10.0 X... Forms : {} Headers : {[Pragma, no-cache], [Content-Length, 1014], [Cache-Control, no-cache], [Content-Type, text/xml; charset=utf-8]...} Images : {} InputFields : {} Links : {} ParsedHtml : System.__ComObject RawContentLength : 1014 <?xml version="1.0" encoding="UTF-8" ?><prtg><result><channel>AX-webserverState</channel><value>0</value><LimitMaxError>1</LimitMaxError></result></prtg>
Any idea why the "Invoke-Webrequest" is apperantly not executed?