Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@PsychoData
Created October 18, 2017 18:17
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 PsychoData/95ecef8bc8f56dead2edb22789333fdd to your computer and use it in GitHub Desktop.
Save PsychoData/95ecef8bc8f56dead2edb22789333fdd to your computer and use it in GitHub Desktop.
function Get-ProxyAddresses
{
Param(
[Parameter(Mandatory=$true)]
[string[]]$username,
[string[]]$domains = 'domain.com'
)
#Strip off any leading @ signs people may have provided. We'll add these later
$domains = $domains.Replace('@','')
$ProxyAddresses = New-Object System.Collections.ArrayList
foreach ($uname in $username) {
foreach ($domain in $domains ) {
if ($ProxyAddresses.Count -lt 1) {
$ProxyAddresses.Add( "SMTP:$uname@$domain" ) | Out-Null
} else {
$ProxyAddresses.Add( "smtp:$uname@$domain" ) | Out-Null
}
}
}
return $ProxyAddresses
}
Get-ProxyAddress -username 'john.smith', 'james.smith' -domains 'domain.com','domain.net'
SMTP:john.smith@domain.com
smtp:john.smith@domain.net
smtp:james.smith@domain.com
smtp:james.smith@domain.net
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment