Hi there –
I’m having an issue referencing the primary email address of users in active directory. Specifically, I want to set the primary email address of a group of users as an alias (proxyAddresses). Here is what I have:
Set-ADUser -identity $user -Replace @{proxyAddresses= "SMTP:" + $user.EmailAddress}
The code runs, but the proxyaddresses field in Active Directory does not update properly. It only updates to “SMTP:”.
I could delete .emailAddress and simply have the following:
Set-ADUser -identity $user -Replace @{proxyAddresses= "SMTP:" + $user}
and it would update the proxy addresses to SMTP:username.
I could explicitly put the domain name like so:
Set-ADUser -identity $user -Replace @{proxyAddresses= "SMTP:" + $user + "@domain.com
And it would update the proxyaddress properly, but this isn’t ideal since we don’t really have a standardized email address. We have 7 different domains that any one of our employees could use as a primary email address. I want to automate this update a bit more.
All this to say:Â Powershell, for whatever reason, does not understand the .emailAddress property for $user.
Has anybody had this issue? Is there something I’m missing? I’ve enabled RSAT and the script includes “Import-Module ActiveDirectory.”
Edit: I’m so silly. I forgot to import the properties in Get-ADUser. I knew it was something simple. Thanks