Skip to content

Instantly share code, notes, and snippets.

@Dalmirog-zz
Created January 9, 2018 05:37
Show Gist options
  • Save Dalmirog-zz/38a8d5417fcf28680b291cfc9af6face to your computer and use it in GitHub Desktop.
Save Dalmirog-zz/38a8d5417fcf28680b291cfc9af6face to your computer and use it in GitHub Desktop.
cls
##CONFIG##
$OctopusAPIkey = "" #Octopus API Key
$OctopusURL = "" #Octopus root url
$projectName = ""
##PROCESS##
$goodBinding = '[{"protocol":"http","port":"80","host":"","thumbprint":null,"certificateVariable":null,"requireSni":false,"enabled":true}]'
$badBinding = '[]'
$header = @{ "X-Octopus-ApiKey" = $octopusAPIKey }
$allprojects = (Invoke-WebRequest $OctopusURL/api/projects/all -Headers $header).content | ConvertFrom-Json
$project = $allprojects | ?{$_.Name -eq $projectName}
$deploymentProcess = (Invoke-WebRequest ($OctopusURL + $project.links.DeploymentProcess) -Headers $header).content | ConvertFrom-Json
foreach($step in $deploymentProcess.Steps){
foreach($action in $step.Actions){
if($action.Properties.'Octopus.Action.IISWebSite.Bindings' -eq $badBinding){
"step $($action.Name) has bad bindings"
$action.Properties.'Octopus.Action.IISWebSite.Bindings' = $goodBinding
}
else{
"Step [$($step.Name)] is not a bad iis step"
}
}
}
$fixedDeploymentProcessJSON = $deploymentProcess | ConvertTo-Json -Depth 5
Invoke-WebRequest ($OctopusURL + $deploymentProcess.Links.Self) -Headers $header -Body $fixedDeploymentProcessJSON -Method Put
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment