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


Article Comments

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


Apr, 2015 - Permalink

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


Apr, 2015 - Permalink

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?


Apr, 2015 - Permalink