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


Article Comments

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.


Jan, 2017 - Permalink

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


Jan, 2017 - Permalink