Created
January 20, 2014 17:18
-
-
Save kfrancis/8524444 to your computer and use it in GitHub Desktop.
Attempt at replacing the default bindings AFTER OctopusDeploy's feature has completed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if ([System.Version] (Get-ItemProperty -path "HKLM:\Software\Microsoft\Windows NT\CurrentVersion").CurrentVersion -ge [System.Version] "6.1") { Import-Module WebAdministration } else { Add-PSSnapin WebAdministration } | |
Function ReplaceWebsiteBinding($sitename, $oldBinding, $newValue) | |
{ | |
$wsbindings = (Get-ItemProperty -Path "IIS:\Sites\$sitename" -Name Bindings) | |
Write-Host "Found bindings:" | |
Write-Host ($wsbindings.Collection).length | |
for($i=0;$i -lt ($wsbindings.Collection).length;$i++) | |
{ | |
Write-Host ($wsbindings.Collection[$i]).bindingInformation | |
if((($wsbindings.Collection[$i]).bindingInformation).Contains($oldBinding)){ | |
($wsbindings.Collection[$i]).bindingInformation = $newValue; | |
} | |
} | |
Set-ItemProperty -Path "IIS:\Sites\$sitename" -Name Bindings -Value $wsbindings | |
} | |
Write-Host "Starting PostDeploy" | |
$siteName = ("MyApp-" + $OctopusParameters["Octopus.Environment.Name"]) | |
Write-Host $siteName | |
ReplaceWebsiteBinding($siteName, "*:80:", "*:82:") | |
Write-Host "Done." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment