Hello,
I'm getting this error:
Response not wellformed: "(File C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\SqlChecker. ps1 cannot be loaded because the execution of scripts is disabled on this syste m. Please see "get-help about_signing" for more details. At line:1 char:2 + & <<<< 'C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\SqlChe cker.ps1' 'Server=FQDN of server;Database=Master;User Id=XXXXXX;Password =XXXXXX;' 'SELECT Top 1 * FROM spt_monitor'; exit $LASTEXITCODE + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException )" (code: PE132)
I've got the follwoing Powershell script:
param([string]$connectionString, [string]$query)
try
{
$connection = New-Object System.Data.SqlClient.SqlConnection
$connection.ConnectionString = $connectionString
$connection.Open()
$command = $connection.CreateCommand()
$command.CommandText = $query
$result = $command.ExecuteNonQuery()
Write-Host "1:OK"
Exit 0
}
catch [System.Data.SqlClient.SqlException]
{
Write-Host "0:SQL exception"
Exit 2
}
catch
{
Write-Host "0:Error"
Exit 2
}
The server running the Remote Probe and the target server have ExecutionPolicy set to Unrestricted (for testing) --> Set-ExecutionPolicy Unrestricted.
However, I'm still getting the same error. Could you guys point me in the right direction?
Article Comments
Attention: This article is a record of a conversation with the Paessler support team. The information in this conversation is not updated to preserve the historical record. As a result, some of the information or recommendations in this conversation might be out of date.
The PRTG Probe will call the 32bit Powershell, this is important for setting the ExecutionPolicy. Please check if you got the right Powershell.
Regards
Birk Guttmann
Jan, 2015 - Permalink