Hi, StaceD
Great to know that the issue has already been resolved and thanks for sharing the solution so that others experiencing the same thing can easily reference this! Since the Microsoft Q&A community has a policy that "[The question author cannot accept their own answer. They can only accept answers by others Accept answers on Microsoft Q&A | Microsoft Learn]", I'll repost your solution in case you'd like to "[Accept]" the answer : )
--------------
Issue Symptom:
Remove the internal email addresses created when creating a mail contact in Exchange 2019
Resolution:
$mailContacts = Import-Csv -Path "C:\XXXX\MailContactsToUpdate.csv"
#Loop through each contact in the CSV
foreach ($contact in $mailContacts){
# Get the email address from the CSV
$emailAddress = $contact.'Email Address'
# Get the mail contact
$mailContact = Get-MailContact -Identity $emailAddress -ErrorAction SilentlyContinue
# Check if the mail contact exists
if ($mailContact) {
# Get the current email address (proxy addresses)
$currentEmailAddresses = $mailContact.EmailAddresses
# Remove only internal email addresses (proxy addresses starting with "SMTP:")
$updatedEmailAddresses = $currentEmailAddresses | Where-Object { $_ -Clike 'SMTP:*' }
# Allows the set-mailcontact command to run
Get-Mailcontact -Identity $mailContact.Name | Set-Mailcontact -EmailAddressPolicyEnabled $false
# Set the updated email addresses
Set-MailContact -Identity $emailAddress -EmailAddresses $updatedEmailAddresses -ErrorAction Stop
Write-Host "Updated: $emailAddress"
} else {
Write-Host "Mail contact not found: $emailAddress"
}
}