New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


The Powershell script works but PRTG can not execute it properly.

Votes:

0

Your Vote:

Up

Down

Hello scripting support,

Here' my probleme :

$user = "admin"

##mdp

$path = "C:\my\path\to\my\file\myHashPassowrd.txt"

$password = cat $path | convertto-securestring

$cred = New-Object System.Management.Automation.PSCredential($user, $password)

##bypass self-signed certificate

Add-Type @"

        using System.Net;

        using System.Security.Cryptography.X509Certificates;

        public class TrustAllCertsPolicy : ICertificatePolicy

        {

             public bool CheckValidationResult(

             ServicePoint srvPoint, X509Certificate certificate,

             WebRequest request, int certificateProblem)

             {

                 return true;

            }

        }

"@

[System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPolicy

$WebRequest=Invoke-WebRequest -URI 'https://myWifiController.html' -Credential $cred -SessionVariable cisco 

$current_aps = $WebRequest.AllElements | where {$_.name -like "current_aps"} | select value

$current_down_aps = $WebRequest.AllElements | where {$_.name -like "current_down_aps"} | select value

$current_up_aps = $WebRequest.AllElements | where {$_.name -like "current_up_aps"} | select value

Write-Host "<prtg>"

Write-Host "<result>"

Write-Host "<channel>Total d'AP</channel>"

Write-Host "<value>"$current_aps.value"</value>"

Write-Host "</result>"

Write-Host "<result>"

Write-Host "<channel>AP DOWN</channel>"

Write-Host "<value>"$current_down_aps.value"</value>"

Write-Host "</result>"

Write-Host "<result>"

Write-Host "<channel>AP UP</channel>"

Write-Host "<value>"$current_up_aps.value"</value>"

Write-Host "</result>"

Write-Host "<text>Nombre d'AP Down : "$current_down_aps.value"/"$current_aps.value"</text>"

Write-Host "</prtg>"

This script works, here is the output:

<prtg>

<result>

<channel>Total d'AP</channel>

<value> 52 </value>

</result>


<result>

<channel>AP DOWN</channel>

<value> 0 </value>

</result>

<result>

<channel>AP UP</channel>

<value> 52 </value>

</result>

<text>Nombre d'AP Down :  0 / 52 </text>

</prtg>

But, Here is the sensor log :

Add-Type : (0)ÿ: Impossible de trouver le fichier source 'C:\Windows\TEMP\waip3m11.0.cs'
(1)ÿ:         using System.Net;
Au caractŠre C:\Program Files (x86)\PRTG Network Monitor\custom 
sensors\EXEXML\script_CISCO_Controller_AP_status_v4.ps1:34 : 1
+ Add-Type @"
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (error CS2001: I...\waip3m11.0.cs':CompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
 
Add-Type : (0)ÿ: Aucun fichier source sp‚cifi‚
(1)ÿ:         using System.Net;
Au caractŠre C:\Program Files (x86)\PRTG Network Monitor\custom 
sensors\EXEXML\script_CISCO_Controller_AP_status_v4.ps1:34 : 1
+ Add-Type @"
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (warning CS2008:...source sp‚cifi‚:CompilerError) [Add-Type], Exception
    + FullyQualifiedErrorId : SOURCE_CODE_ERROR,Microsoft.PowerShell.Commands.AddTypeCommand
 
Add-Type : Impossible d'ajouter un type. Des erreurs de compilation se sont produites.
Au caractŠre C:\Program Files (x86)\PRTG Network Monitor\custom 
sensors\EXEXML\script_CISCO_Controller_AP_status_v4.ps1:34 : 1
+ Add-Type @"
+ ~~~~~~~~~~~
    + CategoryInfo          : InvalidData : (:) [Add-Type], InvalidOperationException
    + FullyQualifiedErrorId : COMPILER_ERRORS,Microsoft.PowerShell.Commands.AddTypeCommand
 
New-Object : Le type [TrustAllCertsPolicy] est introuvable: v‚rifiez que l'assembly dans lequel il se trouve est 
charg‚.
Au caractŠre C:\Program Files (x86)\PRTG Network Monitor\custom 
sensors\EXEXML\script_CISCO_Controller_AP_status_v4.ps1:49 : 55
+ [System.Net.ServicePointManager]::CertificatePolicy = New-Object TrustAllCertsPo ...
+                                                       ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidType: (:) [New-Object], PSArgumentException
    + FullyQualifiedErrorId : TypeNotFound,Microsoft.PowerShell.Commands.NewObjectCommand
 
Invoke-WebRequest : La connexion sous-jacente a ‚t‚ ferm‚e: Impossible d'‚tablir une relation de confiance pour le 
canal s‚curis‚ SSL/TLS.
Au caractŠre C:\Program Files (x86)\PRTG Network Monitor\custom 
sensors\EXEXML\script_CISCO_Controller_AP_status_v4.ps1:52 : 13
+ $WebRequest=Invoke-WebRequest -URI 'https://myWifiController.html ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation : (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebEx 
   ception
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommand
 
0:   /  </text> </prtg> 

So what am I doing wrong ?

Cordially.

powershell prtg script

Created on Oct 1, 2018 10:35:47 AM by  John Doe (0) 1

Last change on Oct 1, 2018 6:16:13 PM by  Stephan Linke [Paessler Support]



1 Reply

Votes:

0

Your Vote:

Up

Down

Add-Type : (0)ÿ: Impossible de trouver le fichier source 'C:\Windows\TEMP\waip3m11.0.cs' (1)ÿ: using System.Net;

translates to: Can not find the source file

This means you might have an issue with 32-bit vs. 64-bit or the script needs components on the probing server itself.

It is always a good idea to logon as the actual executing user to the PRTG server and try the script to see if there are permission issue. If this is not the case, then investigate 32bit and 64bit.

Sorry - did not translate all of your log-file output, the if there is a .cs file missing in the first place, the rest could be just related to that and is to be discarded until the first issue is resolved.

Regards

Florian Rossmark

www.it-admins.com

Created on Oct 2, 2018 1:49:24 PM by  Florian Rossmark (4,099) 3 2



Please log in or register to enter your reply.


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.