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

Powershell script issues



I'm having issues with the following PowerShell script used to report back on the number of files in a UNC path with a specified extension:

param([string]$P=0, [string]$Ext=0, [int32]$Total=0)

$Total =@(Get-ChildItem $P -filter "$Ext").Count;

if ($Total.Count -lt 10) {
    Write-output "0:ok";
    Write-output "4:not ok";

This runs fine as a standalone PowerShell script, but I get the following back from PRTG:

Response not wellformed: "(AuthorizationManager check failed. At line:1 char:2 + & <<<< 'C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXE\1-File Count.ps1' -p \\\c$\temp\ -ext *.txt; exit $LASTEXITCODE + CategoryInfo : NotSpecified: (:) [], PSSecurityException + FullyQualifiedErrorId : RuntimeException )" (code: PE132)

I've tried all sorts of variations of 'Write-output', 'Write-host' and various forms of output and I just can't get it to work. Can anyone help?

Many thanks


filecount powershell prtg

Created on Jul 28, 2014 2:45:42 PM

Last change on Jul 28, 2014 2:55:03 PM by  Torsten Lindner [Paessler Support]

5 Replies



Hi Simon,

Please execute the following command in a PowerShell (x86) with administrative privileges: Set-ExecutionPolicy Unrestricted

The script should work then :)

Kind regards, Stephan

Created on Jul 31, 2014 11:34:49 AM by  Stephan Linke [Paessler Support]



Hi Stephan,

I've already got the Execution Policy set as you suggested.



Created on Jul 31, 2014 11:59:46 AM



Do other scripts work? Can you create a script like this and test it:

Write-Host "0:Everything okay";
Exit 0;

Do you get the same error there? Then it would indicate that your PowerShell profile is corrupted...

Created on Jul 31, 2014 12:17:51 PM by  Stephan Linke [Paessler Support]

Last change on Jul 31, 2014 12:35:27 PM by  Stephan Linke [Paessler Support]



I have the same issue, but I can use Write-host, I need use a Write-Host and the sensor show Response not wellformed.

Anyone has any update how format accept by prtg with Write-OutPut

Created on Dec 9, 2020 7:36:56 PM



Are you using the correct output with the correct Sensor? What does your output look like? Advanced Sensors always expect XML/JSON output, normal script Sensors expect <counter>:<message>.

Created on Dec 14, 2020 8:21:37 AM by  Stephan Linke [Paessler Support]

Last change on Dec 14, 2020 8:21:48 AM by  Stephan Linke [Paessler Support]

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.