How to remove Proxy address for bulk users on exchange server

 

A good-to-know piece of information is always worth sharing.

During migration, you might encounter challenges with users who have email domains that are non-accepted in Office 365.

While it’s easy to handle this manually for a few users, what if you’re dealing with thousands of users, each with an SMTP address associated with an unnecessary or obsolete domain?

In such cases, you’d likely prefer an efficient approach that doesn’t disrupt other users or production. Here’s an example PowerShell script that can help you achieve this seamlessly:

 

Note: Remember to adapt the script to your specific environment and thoroughly test it before implementing it in production. Happy migrating!

 

#This path will be used to save the output file

Start-Transcript -Path C:\temp\Remove-SMTP-Address.log -Append

# Get all mailboxes

$Mailboxes = Get-Mailbox -ResultSize Unlimited

# Loop through each mailbox

foreach ($Mailbox in $Mailboxes) {

# Change @domain.com to the domain that you want to remove

$Mailbox.EmailAddresses | Where-Object { ($_ -clike “smtp*”) -and ($_ -like “*@domain.com”) } |

# Perform operation on each item

ForEach-Object {

# Remove the -WhatIf parameter after you tested and are sure to remove the secondary email addresses

Set-Mailbox $Mailbox.DistinguishedName -EmailAddresses @{remove = $_ }

# Write output

Write-Host “Removing $_ from $Mailbox Mailbox” -ForegroundColor Green

}

}

Stop-Transcript

 

!!! THANKS FOR READING !!!

Regards,
HARISH KUMAR

Knowledge is not a finite resource to hoard; it’s a boundless treasure that grows when shared.