New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Sensor XML Custom EXE/Script Sensor

Votes:

0

Your Vote:

Up

Down

Hello,

I have a powershell script that looks for some information regarding the state of the backup, how many hours since the last backup.

I tested the script by running it through the PRTG server and it returns the information with the times since the last backup, but in the channel the value is always listed as 0. How do I do to show the hours example 21, only the number 21.

<?xml version="1.0" encoding="UTF-8" ?> <prtg> <result> <channel>Last</channel> <value>22</value> </result> <text>LastBackup</text> </prtg>

custom-sensor exe-script-advanced-sensor powershell

Created on Dec 11, 2018 10:25:57 PM by  caiolima (0) 1

Last change on Dec 12, 2018 8:04:49 AM by  Stephan Linke [Paessler Support]



5 Replies

Votes:

0

Your Vote:

Up

Down

Is the script needed to be run under a certain security context? Did you already try to configure the same in the sensor settings so that the administrative credentials of the same are used? What does the script look like?


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Dec 12, 2018 8:05:40 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

The script is not of any additional level of security.

$DEVICE=$args[0]

$BackupStatus = Invoke-Command -Computername $DEVICE -ScriptBlock { Get-WBSummary }

$hlast=(Get-Date)-($BackupStatus.LastBackupTime)

$h1= $($hlast.Hours).ToString()


$output = @"
<?xml version=`"1.0`" encoding=`"UTF-8`" ?>
<prtg>
<result>
<channel>Last</channel>
<value>$($h1)</value>
</result>
<text>Last Backup</text>
</prtg>
"@
Write-Output $output

Created on Dec 12, 2018 9:57:33 AM by  caiolima (0) 1

Last change on Dec 12, 2018 11:37:32 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

You're not providing any credentials for the Invoke-Command, hence it fails. Check this for more information on the topic.


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Dec 12, 2018 11:38:15 AM by  Stephan Linke [Paessler Support]



Votes:

0

Your Vote:

Up

Down

I was able to do it differently.

I created a script to export to a text file and I put in the sensor a script that reads this file, so I did not have to raise the level of any credentials.

Thanks for the help and collaboration.

Created on Dec 12, 2018 5:45:50 PM by  caiolima (0) 1



Votes:

0

Your Vote:

Up

Down

Glad it's up and running now :)


PRTG Scheduler | PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Dec 13, 2018 7:49:54 AM by  Stephan Linke [Paessler Support]



Please log in or register to enter your reply.


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.