Replace Exchange Contact Domain with New Domain For All Contacts

Welcome Forums General PowerShell Q&A Replace Exchange Contact Domain with New Domain For All Contacts

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 4 months ago.

  • Author
    Posts
  • #74144

    Participant
    Points: 0
    Rank: Member

    Hello,
    I am looking for some assistance with a powershell script that will search an OU that contains my Exchange Contacts based off of "@domain.com" value and then replaces only the "@domain.com" with "@newdomain.com" When looking in the exchange properties of the contact the value is "External email address" Any assistance on this is greatly appreciated.
    Thank You,

  • #74170

    Participant
    Points: -12
    Rank: Member

    Hi

    One way to query contacts from AD is

    Get-ADObject -LDAPFilter "ObjectClass=Contact"

    Link for more: https://technet.microsoft.com/en-us/library/ee617198.aspx

    Here you can use -SearchBase if you know the AD OU and pipe it to Where-Object and look only those "external email address" users. Then pipe it to Set-ADObject and -replace the domain. I think you might need to do a little bit splitting here also on the mailaddress.

    Regards

    Jarkko

  • #74182

    Participant
    Points: 0
    Rank: Member

    Thanks for the reply,

    I was able to get this working with the following exchange powershell:

    $users = Get-MailContact -OrganizationalUnit "Domain/User Accounts/test" |
    where ExternalEmailAddress -like "*@olddoman.com*"

    foreach($user in $users){
    Set-MailContact $user.name -ExternalEmailAddress `
    ($user.ExternalEmailAddress -replace "olddomain.com","newdomain.com") -Verbose
    }

The topic ‘Replace Exchange Contact Domain with New Domain For All Contacts’ is closed to new replies.