Skip to content

Instantly share code, notes, and snippets.

@pawelpabich
Created July 29, 2014 22:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pawelpabich/ad4a93ae179ee7642d3d to your computer and use it in GitHub Desktop.
Save pawelpabich/ad4a93ae179ee7642d3d to your computer and use it in GitHub Desktop.
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