Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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