Created
July 29, 2014 22:45
-
-
Save pawelpabich/ad4a93ae179ee7642d3d to your computer and use it in GitHub Desktop.
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
function Set-EmailServerDetails([Parameter(Mandatory=$true)]$IISSite) | |
{ | |
$EmailServerUserName = Retrieve-OctopusVariableIfExists -Name "EmailServerUserName"; | |
if ($EmailServerUserName -ne $null) | |
{ | |
Set-WebConfigurationProperty -Filter "/system.net/mailSettings/smtp/network" -Name "userName" -PSPath $IISSite -Value $EmailServerUserName | |
Log "EmailServerUserName key has been updated"; | |
} | |
$EmailServerPassword = Retrieve-OctopusVariableIfExists -Name "EmailServerPassword"; | |
if ($EmailServerPassword -ne $null) | |
{ | |
Set-WebConfigurationProperty -Filter "/system.net/mailSettings/smtp/network" -Name "password" -PSPath $IISSite -Value $EmailServerPassword | |
Log "EmailServerPassword key has been updated"; | |
} | |
} | |
function Retrieve-OctopusVariableIfExists([Parameter(Mandatory=$true)]$Name) | |
{ | |
if (Test-Path variable:global:OctopusParameters) | |
{ | |
$Value = $OctopusParameters[$Name]; | |
if ($Value -ne $null) | |
{ | |
Log-Debug "Octopus variable [$Name] is present" | |
return $Value; | |
} | |
return $null; | |
} | |
return $null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment