Office 365Tips

Add Email Alias to all users in 365, DirSync

  • Needs to be run on local AD server.
  • Can change “smtp” to capitals to make it the default reply address.
  • Can add “$newproxy2” and repeat the bottom section, changing the $newproxy bit at the end, to add mutiple addresses at once.
  • Can run at the top level OU and it will populate down.

 

Import-Module ActiveDirectory

$newproxy = “@domainname.com”
$userou = ‘ou=Users,ou=Directory Sync,ou=Org,dc=domain,dc=domain,dc=com’
$users = Get-ADUser -Filter * -SearchBase $userou -Properties SamAccountName, ProxyAddresses

Foreach ($user in $users) {
Set-ADUser -Identity $user.samaccountname -Add @{Proxyaddresses=”smtp:”+$user.samaccountname+”.”+$newproxy}
}