How to pass parameters to scripts when using a script file inside a package

I’d like to pass a parameter to a script file inside a package during my deployment process, something like scripts\ConfigureApplication.ps1 -Environment Dev for my development evironment, scripts\ConfigureApplication.ps1 -Environment ProdNY for production, etc. The environment names in Octopus won’t map directly to the environment names in my script. How can I accomplish this?


Thanks for getting in touch. We do this for some of our own projects too, where we want a PowerShell script we can call with arguments from the command-line, like this: "$PSScriptRoot\publish.ps1" -environment $environment -version $version -accessToken $accessToken This means our script doesn’t have to be “Octopus-aware”, but we have another script mapping from our Octopus-aware-world into our vanilla scripts.

Here’s this specific example where we’ve used Custom Scripts to call our PowerShell script with arguments:

Hope that helps!

Thanks Mike, that did the trick.