The “Run a Script” template offers two options for Script Source:
I first selected the second option, “Script file inside a package”, referenced a PowerShell script, and added a few script parameters:
Later, I changed my mind and changed the script source to “Inline Source Code”. Note that there are no parameters here, just the PowerShell script body.
When I ran the deployment, the script failed with “ObjectNotFound: the term -myParameter is not recognized…”. It seems like Octopus passed the script parameters which I specified earlier in the “Script file inside a package” selection to the inline script, which is unexpected.
Temporarily switching back to “Script file inside a package”, removing the parameters, and switching back to “Inline source code” again fixed the problem.