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 Custom Sensor Parmeter Array

Votes:

0

I am currently developing a script to check the SSL Cert expiration for multiple Domains. Therefore I wrote a script starting with

param([String[]] $urls)
Write-Host "<prtg>"

foreach ($url in $urls){
	...
}

Write-Host "</prtg>"

If I run this directly from powershell .\myScript.ps1 host1.com,host2.de,host3.org it runs perfect. If I add the script as XML Custom EXE/Script Sensor it does not loop through the parameters. Somehow host1.com,host2.de,host3.org is not passed as array. It is passed as string and I get

-736809 # (host1.com,host2.de,host3.org) is below the error limit of....

How do I have to pass the arguments to be looped through the foreach loop?

Kind regards, Steff

custom-sensor powershell prtg

Created on Apr 26, 2018 12:22:03 PM

Last change on Apr 26, 2018 8:28:02 PM by  Felix Saure [Paessler Support]



6 Replies

Votes:

0

Hi Steff,

I suppose you just need to extend your script with a split() command to retrieve the domains as string array.

$urlList = $url.split(",")

This should work.

Regards, Jo

Created on Apr 27, 2018 10:17:53 AM



Votes:

0

Either that what Jo said or pass the array in the parameters: -Urls @("www.google.com","www.heise.de")


Kind regards,
Stephan Linke, Tech Support Team

Created on Apr 27, 2018 10:44:27 AM by  Stephan Linke [Paessler Support]

Last change on Apr 27, 2018 10:44:45 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thank you Jo Thank you Stephan

For the sake of simplicity to the Enduser, i've implemented the solution from Jo. It works perfectley.

I'would like to publish the script. Where should i do this?

Kind regards and thanks a lot for your support.

Steff

Created on Apr 27, 2018 11:02:19 AM



Votes:

0

Steff, simply send it to [email protected] and we'll take a look - and put it into Script World eventually :)


Kind regards,
Stephan Linke, Tech Support Team

Created on Apr 27, 2018 12:06:51 PM by  Stephan Linke [Paessler Support]

Last change on Apr 27, 2018 12:07:03 PM by  Stephan Linke [Paessler Support]



Votes:

0

Created on May 4, 2018 5:06:02 AM



Votes:

0

Nice work, I'll put it into Sensor World and post the link when done :) Thanks for your efforts!

edit already done by others ;)


Kind regards,
Stephan Linke, Tech Support Team

Created on May 4, 2018 5:41:54 AM by  Stephan Linke [Paessler Support]

Last change on May 4, 2018 7:53:54 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.