set-mailbox script, Reply To email address

Brass Contributor

Hey Team, 


I have a request to accomplish the following.


  1. Create several hundred user accounts , license them. 
  2. set the smtp address on each of the users mailboxes
  3. list of names coming from a spreadsheet 

I have successfully taken care of the 1st step using this command: 


$Importlist = Import-CSV Testlist.csv


foreach ($SingleImport in $importlist)


    New-MsolUser -DisplayName $SingleImport.Name -Department "Agency OWNER - TSR" -UserPrincipalName $SingleImport.UPN -UsageLocation US -LicenseAssignment TenantNameUAT:STANDARDPACK -ForceChangePassword $False



The first part works as stated. 


This part however does not work:


Set-Mailbox -identity $SingleImport.UPN -EmailAddresses "SMTP:$SingleImport.Email_id", "smtp:$SingleImport.UPN"


All i want to do with the above command is to: 1) Add a new SMTP Address, and set the new address as reply-to. 


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


If i try using the @Add{SMTP:address} it fails with the error stating that another address is already set as reply. 


I just cant seem to get past the Array Error. 





3 Replies
Use the -WindowsEmailAddress parameter, it will set the address you specify as the primary SMTP one, while keeping the old one as secondary alias:

Set-Mailbox -WindowsEmailAddress
Thanks Vasil. I will give that a try. However can you explain why i got that error message? I would really like to understand why my script didn't work.

Interestingly if i type this:

Set-Mailbox -identity -EmailAddresses "", "" - it works.

I just can't quite figure out why i get this error message:

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

or what the error message really means. if not that's fine too. always appreciate your assistance.
best response confirmed by Robert Bollinger (Brass Contributor)
It's not formatted properly, you are referencing a property of an object in there, and the quotes complicate things. Instead of "SMTP:$SingleImport.Email_id", use something like "SMTP:$($SingleImport.Email_id)"