Additional Alias'

This topic contains 6 replies, has 4 voices, and was last updated by  Andy 1 year, 5 months ago.

  • Author
  • #59377


    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".

  • #59382

    Matt McNabb

    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.

  • #59403


    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.

    • #59589

      Max Kozlov

      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 🙂

  • #59452


    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.

    • #59499


      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.

  • #59610


    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}}

You must be logged in to reply to this topic.