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

Can't make powershell script working (PE018)



Hello, I have PowerShell script which runs in the PowerShell CLI but getting the following error from prtg "Your request has timed out. Depending on the sensor type you use, the reason might be that the sensor could not connect to the target host or that a PowerShell command takes too long to execute. For more information, see https://kb.paessler.com/en/topic/71899 or https://kb.paessler.com/en/topic/37633. (code: PE018)"

this is the code of the script:

echo 0 | openssl s_client -host google.com -port 443 -prexit -showcerts > AllCertificates  2>$null
[string[]]$arrayFromFile = Get-Content -Path .\AllCertificates
                if ($arrayFromFile[$i] -eq "Server certificate")

if ($arrayFromFile[$i] -eq '-----Begin Certificate-----')
           while ($arrayFromFile[$i] -ne '-----End Certificate-----')
                Write $arrayFromFile[$i] >> .\sslToCheck.crt
                Write $arrayFromFile[$i] >> .\sslToCheck.crt

                $file = Get-Content .\sslToCheck.crt

                #Regex pattern to compare two strings
                $pattern = "-----BEGIN CERTIFICATE-----(.*?)-----END CERTIFICATE-----"
                #Perform the opperation
                $result = [regex]::Match($file,$pattern).Groups[1].Value

                #Redirect each certificate to ssl.crt file
                Add-Content .\ssl.crt "-----BEGIN CERTIFICATE-----"
                Add-Content .\ssl.crt "$result"
                Add-Content .\ssl.crt "-----END CERTIFICATE-----"
                #Get-Content .\ssl.crt
                #Return the validation date
                openssl x509 -noout -issuer -dates -subject -in ssl.crt > .\Outcome
                #Put the value into variable - VALIDATION TIME
                $TimeAfter = Get-Content .\Outcome | Select -Index 2
                #Get the name of the Certificate
                $text = openssl x509 -noout -issuer -dates -subject -in ssl.crt
                $separator = "CN ="
                $parts = $text.split($separator)
                $sslName = $parts[-1] # return the part after the separator
                #Parse the Date
                $WordIndex = 1
                $month = ($NotValidAfter -split "\s+",($wordIndex +1 ))[($wordIndex-1)]
                $WordIndex = 2
                $dateNum = ($NotValidAfter -split "\s+",($wordIndex +1 ))[($wordIndex-1)]
                $WordIndex = 4
                $tmpyear = ($NotValidAfter -split "\s+",($wordIndex +1 ))[($wordIndex-1)]
                $tmpyear -as [int] > $null
                $year = $tmpyear%100
                $DateParse1 = "$dateNum-$month-$year"
                $DateParse2 = [datetime]::parseexact($DateParse1, 'dd-MMM-yy', $null)
                $certExpiresIn = ($DateParse2 - $(get-date)).Days
                #The OutPut for each certificate
                #Write-Host Cert for SSL $sslName expires in $certExpiresIn days on $DateParse2
                Clear-Content .\sslToCheck.crt
                Clear-Content .\ssl.crt

                if ($minDays -gt $certExpiresIn)
Write-Host $minDays,":OK"
Exit 0

The script returns the following output in the CLI:

237 :OK

but in the PRTG its showing different errors. this is not the issue of the ExecutionPolicy, we set it to Unrestricted at the level of local machine.


pe018 powershell prtg

Created on Jul 15, 2020 6:19:11 PM

2 Replies



Hi Denis,

Please let me know how long the script needs to be executed on the server where the corresponding Probe runs (32bit Powershell used).
In addition, please let me know which is the used scanning interval and how long is the timeout configured in the Sensor settings?

Created on Jul 16, 2020 6:44:41 AM by  Moritz Heller [Paessler Support]




we have actually solved the issue, by moving the script to EXEXML folder (without changing it) and it ran successfully.

I still do not know the root cause of the issue.

the script running from the core probe itself, and we made adjustments that it will run ok in 32bit PS. the scanning interval is standard 60 seconds.

Created on Jul 18, 2020 9:22:22 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.