Bulk change of ProxyAddresses

by John C. Wray III Friday, September 11, 2015 9:16 AM

I had an issue when moving to office 365 where they gave me the wrong proxy address to use for o365. I needed to make a mass change on the users I set to the wrong address. Here is the script. works pretty well. I could have asked for what to look for and what to change it to. It didn't need to be that fancy.



import-module activedirectory

Write-Host "Beginning to look for example.onmicrosoft.com proxyAddresses..." -foregroundcolor red -BackgroundColor darkmagenta


$AllUsers = Get-ADUser -filter * -properties *

ForEach ($tempUser in $AllUsers) {

if ($tempUser.ProxyAddresses -gt 0) {

if ($tempUser.ProxyAddresses[0].contains("example.onmicrosoft.com")) {

write-host "Found one on user " $tempUser.samaccountName

write-host "Replacing " $tempUser.ProxyAddresses[0] 

$fixedAddress = $tempUser.ProxyAddresses[0] -replace "example.onmicrosoft.com","exampletrading.onmicrosoft.com"

write-host " with " $fixedAddress

$tempUser.ProxyAddresses[0] = $fixedAddress

set-ADUser -instance $tempUser







Exchange | Powershell

Comments are closed