Script Template in Deploy vs. Script Console

I am trying to set IIS auto start for an application with the following command in a script template that uses WebAdministration.

Start-ASApplication -SiteName $parentSite -VirtualPath “/$name”

Assume that $parentSite is “Default Web Site” and $name is the name of an IIS Application under that site that has been set with Set-ASApplication to autostart “All”

When I run the script template as part of a release it will freeze forever on this command and I have to cancel the deployment. But if I paste the entire script template into the script console and replace the variables with constants of the same values it works immediately. Is there any possible difference in how scripts execute in the console from how then execute when deployed that can be a clue to why the deployment is freezing.

Hi Paul,

Thanks for getting in touch! Based on what you are describing I can only assume that your variables are not getting set properly.
As this command ran fine in the script console when you replaced the variables, it runs exactly the same when through a PS script.
So a few questions, where are $parentSite and $name getting defined? Is it a variable in the project, or defined in a step?
Are they scoped outside of the deployment you are running? Are they scoped at all?

I think this is just a case of your might need to call the variables slightly differently based on where they are defined.
Also what version of Octopus are you using?