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

Problem with Powershell Return Value

Votes:

0

Hi,

i'm trying to get get PRTG to execute a Powershell Script to return the number of unregistered XenDesktops. The Script is working without PRTG but wihin PRTG i only get an error message. The weird part is that the Error Message evreytime is Error:PU132*(Code: PE132*), except the * are the real Values from the script. For example if i have 4 unregistered machines i get the message Error: PU1324 (Code: PE1324).

Am i doing anything wrong? Here is the script:

asnp citrix.broker*

$unregistered = Get-BrokerDesktop -SummaryState Unregistered


$unregisteredcount = @($unregistered).Count

if ($unregisteredcount -eq 1)
{
$unregisteredcount = 0;
}


write-host $($unregisteredcount)

The if-Sequnece in the middle i'm using because the script always returns atleast 1.

citrix powershell xendesktop

Created on Oct 29, 2012 10:32:00 AM

Last change on Oct 29, 2012 10:35:35 AM by  Konstantin Wolff [Paessler Support]



2 Replies

Votes:

0

Hi,
the return values (in order for PRTG to understand them) have to be in the format:

value:message
Return Code

where Return code is optional. So in your case the return value should look something like the following:

asnp citrix.broker*

$unregistered = Get-BrokerDesktop -SummaryState Unregistered


$unregisteredcount = @($unregistered).Count

if ($unregisteredcount -eq 1)
{
$unregisteredcount = 0;
}

$returnValue = $unregisteredaccount ":Some Message" 
write-host $returnValue
exit 0

Where the following Exit Codes can be used to control the sensor status in PRTG:

ValueDescription
0OK
1WARNING
2System Error (e.g. a network/socket error)
3Protocol Error (e.g. web server returns a 404)
4Content Error (e.g. a web page does not contain a required word)

For further information see also the documentation.
Best regards

Created on Oct 29, 2012 10:43:11 AM by  Konstantin Wolff [Paessler Support]



Votes:

0

Thanks, that helped!

Created on Oct 29, 2012 10:58:01 AM




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.