Getting odd output from script when adding ProxyAddress, thoughts?

I am running a script to update the ProxyAddress for all users in an particular OU and when I run the script and verify the users information on the GUI I am getting the DistinguishedName + my requested output. Here is my script:

Get-ADUser -Filter * -SearchScope Subtree -SearchBase "OU=PreStageO365,DC=MyDomain,DC=com" | ForEach-Object {Set-ADUser -Identity $_ -Add ${ProxyAddresses=smtp:($_.samaccountname)@MyDomain.com" }} 

When I check the user via AD Users and Computers I am seeing the following

smtp:CN=john.doe,OU=prestageo365,DC=MyDomain,DC=COM.samaccountname)@MyDomain.com

I have also been scripting a bunch of new things for me for a week straight now so it all looks the same to me at this point. May just need to reboot my brain….Ugh!

Any help is much appreciated!

submitted by /u/Im_Pickle_Rick0823
[link] [comments]

Leave a Reply