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

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 sensor returns 0

Votes:

0

Your Vote:

Up

Down

Hi, We're having some trouble getting custom powershell scripts to return correct values to PRTG. The script is being executed by an account with domain admin, so I don't think permissions are a problem. When run manually the script returns the correct value, however when run by PRTG it only ever seems to return 0. We have set the execution policy to unrestricted, but no luck. Any help would be greatly appreciated!! The script is below;

$LastDefUpdate = Get-ItemProperty -Path "hklm:\HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\TrendMicro\PC-cillinNTCorp\CurrentVersion\Misc." -Name PatternDate
$LastDefUpdate = [string]$Lastdefupdate.Patterndate
$Now = get-date
#$Now = $Now.toshortdatestring()
$LastDefDate = ([datetime]::parseexact($lastdefupdate,"yyyyMMdd",$null))#.toshortdatestring()
$Datedifference = $now - $LastDefDate
$Dayssince = $Datedifference.days
$returnvalue = "$Dayssince"+":OK"
write-host $returnvalue

custom-script-exe custom-sensor powershell prtg

Created on Feb 5, 2013 11:30:25 PM by  zacpriday (0) 1

Last change on Mar 19, 2015 3:51:44 PM by  Martina Wittmann [Paessler Support]



1 Reply

Votes:

0

Your Vote:

Up

Down

Hello,

just to check, please bear in mind that PRTG "only" calls the 32bit Powershell 1, did you set the execution policy for this one? Also, please try running the PRTG Probe service under the same account as you've manually ran the script.

best regards.

Created on Feb 6, 2013 4:14:48 PM by  Torsten Lindner [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.