Uncategorized

Remove SMTP Address

Thanks to the blog : –

https://www.exchangecore.com/blog/powershell-removing-secondary-smtp-addresses-specified-domain/

$Mailboxes = Get-Mailbox -result unlimited
$Mailboxes | foreach{
for ($i=0;$i -lt $_.EmailAddresses.Count; $i++)
{
$address = $_.EmailAddresses[$i]
if ($address.IsPrimaryAddress -eq $false -and $address.SmtpAddress -like “*domainToRemove.com” )
{
Write-host($address.AddressString.ToString() | out-file c:\addressesRemoved.txt -append )
$_.EmailAddresses.RemoveAt($i)
$i–
}
}
Set-Mailbox -Identity $_.Identity -EmailAddresses $_.EmailAddresses

Advertisements
Standard

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s