PowerShell scripts running without been invoked

This post was created and closed http://help.octopusdeploy.com/discussions/problems/24598-script-libraries-running-everytime, I ran into the same issue and found the solution, if the script in the library doesn’t have a declaration “like function greetings { Write-Host “Hi”}” and just has a body " Write-Host “Hi”", the script will be executed automatically without been invoked which in my case the script execution was failing as it required parameters and they were not been passed. Also I was having a hard time finding documentation on how to use the Script Libraries, some documentation on that would be really nice.

Hope this helps to other people, this took me a bit to figure out.


Hi Fabian,

Thanks for getting in touch! Sorry about the troubles that you are having.
I have created a task to create better documentation around Script Libraries.
They are designed for reusable functions and are made available for each step.
Having something that you want to be reusable, but not have functions, then using a Step Template would allow for what you want, and only be available/invoked at it’s step number in the process.


That is a great feature with weak documentation, once i figured it out it works great, love how it works!