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"; }else{ 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 \\128.1.16.14\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
Si
Add comment