Author Posts

December 5, 2016 at 1:19 pm

Hi there,

I have an additional alias to add to 100's of user accounts in O365. I was hoping to add these to a .csv file and use powershell to add these.

I don't require these to be primary addresses but just to act as an additional address.

Does anyone know the command to put into Powershell at all? I was provided with one:

$csv = import-csv file.csv
foreach($users in $csv)
set-mailbox $emailaddress -emailaddresses @{add="$secondaryemailaddress"}

When I run this it displays the error message

Cannot process argument transformation on parameter 'EmailAddresses'. Cannot convert value "System.Collections.Hashtable" to type "Microsoft.Exchange.Data.ProxyAddressCollection".

December 5, 2016 at 1:32 pm

What are the values of $EmailAddress and $SecondaryEmailAddress, and where are you populating them? If the only code you're running is what's in the example above, then these values will be null.

December 5, 2016 at 3:51 pm

Need to see the headers of your csv file. I expect it needs to be something like:

set-mailbox $users.emailaddress -emailaddresses @{add="$($users.secondaryemailaddress)"}

Also, don't run this or anything else on your whole list as a test. Edit your csv file to just one user, that way, you only have 1 user to fix if it makes a mess.

December 6, 2016 at 8:52 am

Hi Matt & Ron,

Apologies if my first post wasn't the best. Fairly new to Powershell so slowly getting to grips with it all.

Thankfully I am only testing this on one user so that I don't mess up the entire tenant! I basically have a spreadsheet with 3 columns titled:

users – the contains the users full name
emailaddress – this contains the users primary smtp address
secondaryemailaddress – this contains the email address that I would like to add as an additional alias.

Not sure if this is what you're after but please let me know if not.

December 6, 2016 at 2:45 pm

I guessed right then, try substituting my line for set-mailbox and see if it works. Just make a note of what's currently there so you can fix it.

December 7, 2016 at 8:22 am

Ron, why you suggect use @{add="$($users.secondaryemailaddress)"}
instead of @{ add = $users.secondaryemailaddress } ?
It will spread over internet and get rise to dozens of new wuestions 🙂

December 7, 2016 at 11:17 am

Hi All,

Thanks for your replies.

I managed to get this working in the end using the following:

Import-CSV ".\MultipleAlias.csv" | ForEach {Set-Mailbox $_.Mailbox -EmailAddresses @{add=$_.NewEmailAddress}}