Hi have this ps script
Param
(
[String]$fPath
)
$cont = (Get-ChildItem $fPath -File | ? {$_.LastWriteTime -gt (Get-Date -format "MM/dd/yyyy") }).Count
$xmlstring = "<?xml version=`"1.0`"?>`n <prtg>`n"
$xmlstring += " <result>`n"
$xmlstring += " <channel>File</channel>`n"
$xmlstring += " <unit>Custom</unit>`n"
$xmlstring += " <CustomUnit>num</CustomUnit>`n"
$xmlstring += " <mode>Absolute</mode>`n"
$xmlstring += " <showChart>1</showChart>`n"
$xmlstring += " <showTable>1</showTable>`n"
$xmlstring += " <float>0</float>`n"
$xmlstring += " <value>$cont</value>`n"
$xmlstring += " <LimitMode>1</LimitMode>`n"
$xmlstring += " </result>`n"
$xmlstring += " </prtg>"
Write-Host $xmlstring
If I run this manualy it's ok, but if I can to run this with PRTG EXE/XML Advanded return : Network Path not found
Why???
manually
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> Set-ExecutionPolicy -ExecutionPolicy Unrestricted
PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\checkBKAs400.ps1 -fPath \\192.168.10.21\backup\As400\Sardus\FTP
<?xml version="1.0"?>
<prtg>
<result>
<channel>File Backup</channel>
<unit>Custom</unit>
<CustomUnit>File</CustomUnit>
<mode>Absolute</mode>
<showChart>1</showChart>
<showTable>1</showTable>
<float>0</float>
<value>13</value>
<LimitErrorMsg>Errore nel backup</LimitErrorMsg>
<LimitMode>1</LimitMode>
</result>
</prtg>
EXE Log
Get-ChildItem : Impossibile trovare il percorso '\\192.168.xx.xx\backup\As400\Sardus\ftp' perch‚
non esiste.
In C:\Program Files (x86)\PRTG Network Monitor\custom sensors\EXEXML\checkBKAs400.ps1:8 car:10
+ $cont = (Get-ChildItem -LiteralPath $fPath -File | ? {$_.LastWriteTi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (\\192.168.xx.xx\backup\As400\Sardus\ftp:String) [G
et-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
<?xml version="1.0"?>
<prtg>
<result>
<channel>File Backup</channel>
<unit>Custom</unit>
<CustomUnit>File</CustomUnit>
<mode>Absolute</mode>
<showChart>1</showChart>
<showTable>1</showTable>
<float>0</float>
<value>0</value>
<LimitErrorMsg>Errore nel backup</LimitErrorMsg>
<LimitMode>1</LimitMode>
</result>
</prtg>
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.
Hi,
It seems like while manually running the PS Script, the network path cannot be found either:
Get-ChildItem : Impossibile trovare il percorso '\\192.168.xx.xx\backup\As400\Sardus\ftp' perch‚ non esiste.
If you can get the script to work without this error message, the EXE/XML Advanced sensor in PRTG should work as well.
Mar, 2020 - Permalink
Hi, I try this, but same error.... It's a PS bug???????
C:\Windows\system32>powershell -file "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\checkBKAs400.ps1" "
192.168.xx.xx\backup\As400\Sardus\FTP"
Get-ChildItem : Impossibile trovare il percorso '
192.168.xx.xx\backup\As400\Sardus\FTP' perch‚ non esiste. In C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML\checkBKAs400.ps1:7 car:10 + $cont = (Get-ChildItem -Path "$fPath" -File | ? {$_.LastWriteTime -g ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (
192.168.10.21\backup\As400\Sardus\FTP:String) [Get-ChildItem], ItemNo tFoundException + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand
Mar, 2020 - Permalink