What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags

View all Tags

Powershell script partial runned on probe in other domain




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.


    [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
  { $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>"

$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:

<?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>
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
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?

powershell prtg sensor xml

Created on Jan 13, 2023 10:24:57 AM

Last change on Jan 16, 2023 7:43:07 AM by  Felix Wiesneth [Paessler Support]


Nobody has replied yet

Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.