Hi @sreekanth
It would really help if you format your script. It is really hard to read.
There are a few things:
- It looks like the
return
statement is outside of the function. - The
exit
statement requires an Integer (see this Link).
Soreturn
should only return the exit code in your case. You could add the plugin output withWrite-Host
before returning. - 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