Delete the old SMTP domain from the Exchange 2007 mailbox

This article is made based on the following situation: the company or organization where you work has experienced many sales and changes over the years. During that process, some SMTP domains were no longer owned, and therefore must be removed from the Accepted Domains list in Exchange 2007 and E-mail Address Policies ...

TipsMake.com - This article is made based on the following circumstances: the company or organization where you work has experienced many sales and changes over the years. During that process, some SMTP domains were no longer owned, and therefore must be removed from the Accepted Domains list in Exchange 2007 and E-mail Address Policies. But the problem is that when you do this, it is impossible to delete the email addresses that were associated with the mailbox data section of the user.

For more specific examples, company A sold a branch that operates with the OLDDOMAIN.com domain, so Company A no longer owns that domain and will need to remove all The component is related to OLDDOMAIN.com from the system.

Delete the old SMTP domain from the Exchange 2007 mailbox Picture 1Delete the old SMTP domain from the Exchange 2007 mailbox Picture 1
Screenshot of the properties of any account before we continue processing

Because in fact, there is no function to remove the old domain from the system from the user's E-mail Addresses list (also known as ProxyAddresses ), we can handle it manually in each mailbox section. to remove old address components, or use PowerShell for batch processing.

Some assumptions are made based on user needs:

- You want to use this function on each domain mailbox

- You have full administrative rights or at least have the right permissions to manage the entire mailbox section

- Use this function from Exchange Management Shell

- Replace OLDDOMAIN.com with the domain name component you want to remove from the email address

The code used in this hypothetical situation is as follows:

#Get all mailboxes into an Array
$ mbxs = @ (get-mailbox -Resultsize Unlimited)

#Iterate through each mailbox
foreach ($ mbx in $ mbxs)
{

#Create hai ảnh trong các địa chỉ thư trong trả về thư mục
$ CurrentList = $ mbx.emailaddresses
#the second copy is the one where changes will take place.
$ NewList = $ mbx.emailaddresses

#Iterate qua mỗi địa chỉ trong danh sách danh sách.
foreach ($ Address in $ CurrentList)
{

#see if địa chỉ hiện thời được kết thúc các trường bạn muốn gỡ bỏ
if ($ Address.tostring () -match "OLDDOMAIN.com")
{

#If được tìm thấy match, gỡ bỏ địa chỉ từ từ danh sách.
$ NewList - = $ Address

}

}

#Overwrite the old list with new list.
set-mailbox $ mbx -emailaddresses $ NewList

}

When the test is completed with the newly provided code, the results are very positive, so it will be very effective when applied in practice.

Delete the old SMTP domain from the Exchange 2007 mailbox Picture 2Delete the old SMTP domain from the Exchange 2007 mailbox Picture 2
The entire section of OLDDOMAIN.com SMTP address has been successfully deleted

But everyone should keep in mind that the above code only works on Exchange 2007 platform, doesn't work with Exchange 2010. Wish you success!

4.5 ★ | 2 Vote