Execute powershell script for checking the URL's

Hi @sreekanth

It would really help if you format your script. It is really hard to read.
There are a few things:

  1. It looks like the return statement is outside of the function.
  2. The exit statement requires an Integer (see this Link).
    So return should only return the exit code in your case. You could add the plugin output with Write-Host before returning.
  3. The catch statement will catch any exception. Maybe you could add the exception message to the plugin output.

There are lots of powershell plugins on the icinga exchange which may give you a good idea on developing your own plugins.
Also: If you plan on using the icinga powershell framework, there’s a full step-by-step tutorial on how to write custom plugins for it.

Kind regards

1 Like