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

XML Sensor

Votes:

0

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>

prtg sensor xml

Created on Mar 30, 2020 3:29:04 PM

Last change on Mar 31, 2020 4:18:27 AM by  Sven Roggenhofer [Paessler Technical Support]



2 Replies

Votes:

0

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

Created on Mar 31, 2020 8:51:50 AM



Votes:

0

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.

Created on Mar 31, 2020 9:25:40 AM by  Timo Dambach [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.