Modify Proxyaddresses Domain

This powershell snippet is used to replace a domain in all values in a user’s proxyAddresses attribute.  It requires using Microsoft’s ActiveDirectory module.  It is is capable of bulk modifying all users in an OU or can modify a single user if you specify their DN.  In the script below, modify the SearchBase and replace @olddomain.com and @newdomain.com.

Import-Module ActiveDirectory
Get-ADUser -Filter * -SearchBase 'OU=Test,DC=domain,DC=local' -Properties proxyaddresses | Foreach {Set-ADUser -identity $_ -Replace @{'ProxyAddresses' = @($_.proxyaddresses -Replace "@olddomain.com","@newdomain.com")}}