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

Custom Sensor PS Script

Votes:

0

I'm getting the following error on a custom sensor: Response not well-formed: "(A command that prompts the user failed because the host program or the command type does not support user interaction. Try a host program that supports user interaction, such as the Windows PowerShell Console or Windows PowerShell ISE, and remove prompt-related commands from command types that do not support user interaction, such as Windows PowerShell workflows. )" (code: PE132) This is the script I'm running:

#gets the file and its last line
$and = (Get-Content \\computername\c$\folder\DB\license.lic)[-1]

#separates each value by finding every space
$separator = " "

#removes repeating separators since there are multiple spaces
$opt = [System.StringSplitOptions]::RemoveEmptyEntries

#sets the split as a value
$drew = $and.Split($separator,$opt)

#runs the command and, counting left, writes the sixth position from the far right to a variable for collection, tags it with an identifier for PRTG
write-host $drew[6] ":Current Users"

#write status of normal to PRTG
exit 0

If I add the following to my script, the sensor changes from "Down" to "Up", but it does not return the count I'm looking for: value:ok Can anyone offer any suggestions?

powershell prtg ps1

Created on Aug 3, 2021 3:20:28 PM

Last change on Aug 4, 2021 5:46:14 AM by  Felix Wiesneth [Paessler Support]



3 Replies

Votes:

0

Hi there,

Please try to use write-output instead of write-host Please check if the issue occurs again afterwards.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Aug 4, 2021 6:57:07 AM by  Felix Wiesneth [Paessler Support]

Last change on Aug 4, 2021 6:57:15 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

The sensor is now up with no errors after changing it to write-output However, the result is returning Value 0. When I run the script manually, the expected result is returned appropriately.

Created on Aug 4, 2021 7:21:34 AM



Votes:

0

Hi there,

Good to hear that the sensor is up and running. Since it seems from first look good, I would recommend to check our guide for PowerShell based sensors.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Aug 4, 2021 11:01:19 AM by  Felix Wiesneth [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.