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

Remote Powershell on non-domain hosts

Votes:

0

Hi,

I wrote a ps1-Script that executes remote on hosts to monitor connectivity of routes:

param (
 [string]$computerName = "127.0.0.1",
 [string]$target = "127.0.0.1"
)

Try{
	$res = Test-Connection -Source $computerName -ComputerName $target
	$retTime=$res[0].ResponseTime
	write-host ([string]::Format("{1}: Antwort von {0} in {1} ms",$target,$retTime))
	Exit 0
}
Catch{
 write-host ([string]::Format("0: Ziel {0} nicht erreichbar! {1}",$target, $_.Exception.Message))
 Exit 1
}

I created exesensors for several devices, using parameters like "-computerName %host -target 8.8.8.8" and the security context of the device. The script runs well on domain members (using domain name and username from device settings), but fails on a workgroup machines with Access denied (PE095).

Credentials for the workgroup machine are set with machine name and "Administrator", according to the manual this should result in the local user "Administrator" then.

On the PRTG probe server I added the above box as trusted host:

Set-Item WSMan:\localhost\Client\TrustedHosts -Value myworkgroupbox
Restart-Service WinRM

The workgroup machine was configured for remote powershell:

Set-ExecutionPolicy Unrestricted

but I still get this error! Note: all powershell settings were made with x86 PS.

From a powershell window on the probe this works like expected:

Test-Connection -source myworkgroupbox -computername 8.8.8.8 -Credential myworkgroupbox\Administrator

I highly appreciate any help with this,

Stefan

custom-script-exe powershell remote script

Created on Jan 12, 2017 3:22:49 PM



2 Replies

Votes:

0

Dear Stefan

Did you set that execution policy for the Powershell x86 (32-bit) version? Since the probe is a 32-bit service, it uses the 32-bit powershell.

Created on Jan 13, 2017 12:29:27 PM by  Arne Seifert [Paessler Support]



Votes:

1

Yes, all using x86 Powershell. However, I found the problem in the meanwhile: The script fails because the sensor tries to execute the script on the probe using the credentials of the non-domain member - of course that fails. I rewrote the script to use %windowsuser and %windowspassword to build PSCredentials and provide that to the remotely executed method. This works well.

I'll polish the code, add some docs and repost it as a custom sensor KB entry next week.

Thanks,

Stefan

Created on Jan 13, 2017 1:13:10 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.