Set the mail attribute from the UPN

If you use Office 365 with DirSync you’ll know that the email aliases and default reply address are set by the AD attributes mail and proxyAddresses.

If you only need the one alias, and for that alias to be the default reply address, it is sufficient to populate the mail attribute in Active Directory.

I prefer to have the mail and UPN have the same value. To copy the UPN value to the mail attribute for all users without a mail value, open a PowerShell window as an admin on a DC, and import the Active Directory module.

Import-Module ActiveDirectory

Then run the following command, changing the OU as required to suit your purposes.

Get-ADUser -SearchBase "CN=Users,DC=Contoso,DC=com" -filter * -Properties * | Where { $_.emailaddress -eq $null } | % { Set-ADUser -emailaddress $_.userprincipalname }

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s