What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

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

Sensor not displaying same output as powershell.

Votes:

0

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.

datatype exe integer powershell

Created on Aug 28, 2021 2:02:35 AM

Last change on Aug 30, 2021 6:26:33 AM by  Felix Wiesneth [Paessler Support]



2 Replies

Votes:

0

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

Created on Aug 30, 2021 11:29:46 AM by  Felix Saure [Paessler Support]



Votes:

0

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

Created on Aug 30, 2021 4:45:20 PM




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.