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

Article Comments

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.


Feb, 2013 - Permalink