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

Custom sensor: Get-Process with Powershell

Votes:

0

Hi,

I have a simple Powershell script:

=====\\
Get-Process -ComputerName "REMOTE-COMPUTER" >> "C:\TEMP\result.txt"\\
echo "0: Ok"\\
Exit 0\\
=====

- From Powershell console it's Ok - From PRTG custom sensor doesn't work => This file result.txt is empty

I have no error in PRTG...

Have you an idea?

Thank's

get-process powershell script

Created on Apr 7, 2015 12:50:39 PM

Last change on Apr 7, 2015 12:54:39 PM by  Torsten Lindner [Paessler Support]



3 Replies

Votes:

0

Hi,
When calling get-process directly you are authenticating as the calling user against the remote machine. In case of PRTG this is LOCAL SYSTEM which has no permissions at all on the remote machine. Try using invoke-command and pass explicit credentials, example code below:

param(
    [string]$user = "USERNAME",
    [string]$domain = "DOMAIN",
    [string]$password = "PASSWORD",
    [string]$target = "TARGETCOMPUTER"
)

$secpassword = $password | ConvertTo-SecureString -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential(("{0}\{1}" -f ,$domain, $user), $secpassword)

Invoke-Command {get-Process} -ComputerName $name -Credential $creds
# Do your stuff

Best regards

Created on Apr 8, 2015 11:52:25 AM by  Konstantin Wolff [Paessler Support]



Votes:

0

Hi,

Thanks for your response.

This is not a bug?

My PRTG service is started with a Domain User, it should not run Powershell also with this user?

Thanks

Created on Apr 9, 2015 7:20:47 AM



Votes:

0

Although the PRTG Probe service might be running with an AD user, explicit authentication might be necessary. So please try adjusting your script to use explicit authentication. Does the script work then?

Created on Apr 10, 2015 11:38:26 AM by  Konstantin Wolff [Paessler Support]




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.