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
Article Comments
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
Apr, 2018 - Permalink
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
Apr, 2018 - Permalink
Steff, simply send it to support@paessler.com and we'll take a look - and put it into Script World eventually :)
Kind regards,
Stephan Linke, Tech Support Team
Apr, 2018 - Permalink
This is exactly what I did. https://github.com/TS-Steff/PRTG-Multiple-SSL-Cert-Day-Until-Expiration
May, 2018 - Permalink
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
May, 2018 - Permalink
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
Apr, 2018 - Permalink