I monitor a lot with the powershell script monitor components. Some times I have the same powershell script in an application more than 10 times. So if I want to change something in the script I have to go to the template and change the same lines in each of the component.
Therefore I thought I build an wrapper, that would make it possible to just change the lines at the script locally.
At this time my wrapper looks like this:
My first parameter is the path to the script that should be run (called script). All other parameters will be forwarded to the script defined in the first parameter.
For test purposes I wrote this test script
If I run the wrapper script locally I get this output:
But I want to run this in SAM, I get no output. So I added some output in the wrapper script in SAM:
It seems that just the output of the wrapper script is used for statistic and messages.
Do you have any idea to get the output of the called script?
If you have any improvments please tell me 🙂
@jm_sysadmin I tried this but another problem occurred. If I use dot sourcing all parameters are passed as an array to the called script. This means all passed parameters are stored in an array in $args. So if I want to access the agruments in the called script I have to access them like $args or $args and so on.
SolarWinds solutions are rooted in our deep connection to our user base in the THWACK® online community. More than 150,000 members are here to solve problems, share technology and best practices, and directly contribute to our product development process. Learn more today by joining now.