Set default email for Office 365
| August 6th, 2017Powershell script to set default email for all AD users
Depending on the information stored for the users in the AD, there is two ways this can be accomplished:
1.Set email field and default email in ProxyAddresses according to UserPrincipalName:
$users = Get-ADUser -Filter * -properties EmailAddress -SearchBase "ou=Test,ou=Departments,dc=DOMAIN,dc=COM" foreach ($user in $users) { $useremail = $user.UserPrincipalName Set-ADUser $user -Add @{'ProxyAddresses' = ("SMTP:"+$useremail )} -EmailAddress $useremail }
2. Set default email in ProxyAddresses according to email field:
$users = Get-ADUser -Filter * -properties EmailAddress -SearchBase "ou=Test,ou=Departments,dc=DOMAIN,dc=COM" foreach ($user in $users) { $useremail = $user.EmailAddress Set-ADUser $user -Add @{'ProxyAddresses' = ("SMTP:"+$useremail )} }