How to: Remove domain-specific Public Folder SMTP proxy addresses

In preparation for migrating legacy Public Folders to Exchange 2016, I needed to remove a large number of SMTP proxy addresses that that used the “@local” domain, created by an old email address policy.

Many scripts exist for this purpose, should you only need to update mailboxes, however I was unable to find anything that targeted Public Folders.

The below script is a derivative of Ali Tajran’s mailbox script, which can be found here.

# Script published at

# Remove "-WhatIf" from line 18 when you are happy with your changes.

# Output will be added to C:\temp folder. Open the Remove-SMTP-Address.log with a text editor.
Start-Transcript -Path C:\temp\Remove-SMTP-Address.log -Append

# Get all Public Folders
$PFs = Get-MailPublicFolder -ResultSize Unlimited
# Loop through each Public Folder
foreach ($PF in $PFs) {

    # Change to the domain that you want to remove
    $PF.EmailAddresses | Where-Object { $_.AddressString -like "*" } | ForEach-Object {
        # Remove the -WhatIf parameter after you tested and are sure to remove the secondary email addresses
        Set-MailPublicFolder $PF.Identity -EmailAddresses @{remove = $_ } -WhatIf
        # Write output
        Write-Host "Removing $_ from $PF Public Folder" -ForegroundColor Green


Leave a comment