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
Add comment