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

Script Sensor Output differences (Powershell / PRTG)

Votes:

0

We are currently having a problem with a script sensor that leverages the citrix broker plugins to check if a machien is in maintenance mode, When testing the script on the PRTG server directly the output is showing correctly however the value of the output from within PRTG is showing incorrectly.

Do scripts within PRTG run differently in any way? potentially an issue with the variables?

Script:

asnp Citrix.broker*

function MaintenanceModeValue () {

$MaintenanceMode = Get-BrokerMachine -MachineName <machine name> -adminaddress <Delivery controller> | select InMaintenanceMode -ExpandProperty InMaintenanceMode

If ($MaintenanceMode -eq $False) { 
Write-Host "0:Maintenance Mode Disabled"; } 
Else { 
Write-Host "2:Maintenance Mode Enabled";  }
}

MaintenanceModeValue;

The output received is always "2:Maintenance Mode Enabled" despite what the actual value of InMaintenanceMode is. Also, If I change the equals factor to $True instead of $False the script still outputs "2:Maintenance Mode Enabled". this makes me believe that when the script runs in PRTG the $MaintenanceMode Variable is reporting back with something other than either true or false.

as mentioned before the script runs perfectly when running within powershell directly from the server that hosts PRTG

Is there a way that i can test the output of what PRTG is actually seeing when running the script?

custom-script-exe powershell sensor

Created on Apr 28, 2020 9:25:03 AM

Last change on Apr 28, 2020 1:34:50 PM by  Stephan Linke [Paessler Support]



1 Reply

Votes:

0

Hi there,

Thank you for your Knowledge-Base post.

PRTG executes Powershell with the parameter -NoProfile.
Can you please try to start "powershell.exe -noprofile" and run your script again? Does this make any difference?

You can also set the option "EXE Result" to "Write EXE result to disk" in your sensor configuration. This will generate two files with the names "Result of Sensor $ID.txt" and "Result of Sensor $ID.Data.txt in the folder "%programdata%\Paessler\PRTG Network Monitor\Logs\sensors". $ID is replaced with the ID of your sensor. Please paste the results here and make sure that any confidential data is redacted beforehand.

Please also check the following Knowledge-Base articles about Custom PowerShell scripts:
- https://kb.paessler.com/en/topic/71356-guide-for-powershell-based-custom-sensors
- https://kb.paessler.com/en/topic/80145-custom-exe-powershell-script-running-on-core-not-target
- https://kb.paessler.com/en/topic/69565-customer-powershell-script-returns-no-response


Kind regards,
Matthias Kupfer - Team Tech Support

Created on Apr 29, 2020 8:47:02 AM by  Matthias Kupfer [Paessler Support]




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.