IIS start issue

I am new to octopus deployment and every time on deployment my world wide web service does not start automatically.
My code to start and stop the services is
$wait = $OctopusParameters[“iisWait”] -and [boolean]::Parse($OctopusParameters[“iisWait”])
$action = $OctopusParameters[“iisAction”]
$errorAction = $OctopusParameters[“iisErrorAction”]
if ($Action -eq “/RESTART”) { Write-Host “Restarting IIS” }
elseif ($Action -eq “/START”) { Write-Host “Starting IIS” }
elseif ($Action -eq “/STOP”) { Write-Host “Stopping IIS” }
else {
Write-Error “Unknown action $action”
exit 1

if (($errorAction -ne “Stop”) -and ($errorAction -ne “Continue”) -and ($errorAction -ne “SilentlyContinue”)) {
Write-Error “Unknown ErrorAction $errorAction”
exit 1

if ($wait) {
Write-Host “Running with wait”
Start-Process -FilePath “iisreset” -ArgumentList $Action -ErrorAction $OctopusParameters[“iisErrorAction”] -Wait
else {
Write-Host “Running without wait”
Start-Process -FilePath “iisreset” -ArgumentList $Action -ErrorAction $OctopusParameters[“iisErrorAction”]

Hi @paggarwal5154,

Thanks for getting in touch.

We have Community step templates that will do this for you.

You can stop the site using https://library.octopus.com/step-templates/9eb40453-ac5d-4cb0-8666-046ff6305a3a/actiontemplate-iis-website-stop

You can start the site using https://library.octopus.com/step-templates/2b2cf57e-24fa-4094-9513-89647fe5f807/actiontemplate-iis-website-start

I use these sometimes when IIS doesn’t let go of tasks during a deployment. You can also use the Stop and Start Service Step templates found on https://library.octopus.com/step-templates/6fa0fab6-4799-4d81-944d-3c7b54530870/actiontemplate-stop-service-with-kill and on https://library.octopus.com/step-templates/60733bf3-1617-4d85-a40f-4b6a0b9289ef/actiontemplate-windows-service-start

We have a sample that uses the Stop Service and Start Service approach on https://samples.octopus.app/app#/Spaces-202/projects/octofx/deployments/process/steps?actionId=68b92203-1b25-4a44-a57e-e70fa015336b that you can see using these.

Please let me know if you have any questions,



Thanks Derek, this is really helpful, thanks

Thanks, @paggarwal5154!

Just get in touch if we can help with anything further.

Happy Deployments!


This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.