Created
October 18, 2017 18:17
-
-
Save PsychoData/95ecef8bc8f56dead2edb22789333fdd 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 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:[email protected] | |
smtp:[email protected] | |
smtp:[email protected] | |
smtp:[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment