Hello all I have the following powershell script:

$message = "OK"
$urbackuphost = "ics-urbackup.ad.icsanalytics.com"
$count = Invoke-Command -ComputerName $urbackuphost -ScriptBlock { Invoke-SQliteQuery -Query "select count() from clients WHERE lastbackup_image < datetime('now', '-1 hours')" -DataSource "C:\Program Files\UrBackupServer\urbackup\backup_server.db" | ConvertTo-Csv | select -skip 2  }


if ($count -gt 0){
    $message = "ERROR"
    }
#$count = 0
Write-Host $count":"$message

Essentially I query a sqlite database table to see if some items are past a certain date and to count them. When I run the powershell script locally on the PRTG machine it returns the values and the write-host message as expected.

For instance the script as it sits right now ran at the time of post would result in a write-host output of

7:ERROR

However my sensor displays 0.

If I uncomment out the line that starts with #$count and set the value to $count manually to ANY number. It will correctly display in the sensor. I thought this was maybe something to do with integers vs strings, but I've converted $count to integer and vice versa and nothing seems to work.


Article Comments

Hi Jared,

Thanks for reaching out to us!

This is most likely related to the user context of the script. Did you ensure that:

  • The Use Windows credentials of parent device and ensure that the user entered there has sufficient rights
  • Check if the PowerShell script runs with that user. Also confirm that it's an x86 PowerShell, since PRTG is a 32 bit process.

Kind regards,
Felix Saure, Tech Support Team


Aug, 2021 - Permalink

I changed to Use Windows Credentials of parent device and was able to return a result.


Aug, 2021 - Permalink