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

EXE/SCRIPT SENSOR Powershell not running on remote system.

Votes:

0

I am running a powershell script sensor on a remote windows machine. The script checks for logon audit failures:

$count = (get-eventlog security -after (get-date).AddDays(-1) | where {$_.instanceid -eq 4625}).count write-host "$count`:OK"

The script runs but returns "0:OK" on the sensor (and in the log), however if I run the script on the remote system it returns something different, like "6:OK"

I suspected that the script was returning a value from the PRTG host system, not the remote machine, which I verified with the following:

$hostName = hostname if($hostName -eq "PRTG"){write-host "1:OK"}else{write-host "2:OK"}

And sure enough, the sensor returned "1:OK". So despite the sensor being put in the remote system, it is not running the script on that system.

Not sure where to go from here.

powershell probe remote

Created on Mar 26, 2019 9:16:00 PM



3 Replies

Votes:

0

powershell scripts with custom EXE/XML sensors are running on the remote Probe operating system. if you want the script running on another machine you need to use Remote powershell.

for example

invoke-command -computername $remoteserver -scriptblock {$count = (get-eventlog security -after (get-date).AddDays(-1) | where {$_.instanceid -eq 4625}).count ; write-host "$count`:OK"}

the variable $remoteserver can be filled with the prtg host variable. So you can use the same script for all devices.

Created on Mar 27, 2019 7:59:28 AM



Votes:

0

Thanks for chiming in! :)


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 27, 2019 11:12:48 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi there

Did you get this working?

Would you be able to share the finished script please.. I am really struggling to figure this out.

Kind regards Chad

Created on Mar 24, 2020 8:13:02 AM




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.