Hello Jurgen,
Thank you for your message.
According to your message, the command you are using is performed on the probe server and not on the target one, hence the error message you get. Therefore, I recommend to execute the command remotely by using the following:
param (
[string] $target,
[string] $winuser,
[string] $winpass
)
$credentials = New-Object System.Management.Automation.PSCredential ($winuser, (ConvertTo-SecureString $winpass -AsPlainText -Force))
try {
$counter = Invoke-Command -ComputerName $target -Credential $credentials -Scriptblock {
(Get-Counter @("\Terminal Service Gateway\Current connections") -ComputerName "127.0.0.1").CounterSamples.CookedValue
}
Write-Output "$($counter):Ok"
Exit 0
}
catch {
Write-Output "-1:$($_.exception.message) At line : $($_.InvocationInfo.ScriptLineNumber)"
Exit 1
}
To use it, copy the content within the EXE folder and create a new EXE/Script sensor. Then, add the following in the field Parameters:
-target "%host" -winuser "%windowsuser" -winpass "%windowspassword"
Make sure that the credentials defined in the parent device settings under Credentials for Windows devices have enough rights to execute the command on the target device.
Please, note that we do not provide official support for customizations. The code above is provided as is (not tested) and might need to be modified to work properly.
Regards.
Add comment