SOLVED

set-mailbox script, Reply To email address

%3CLINGO-SUB%20id%3D%22lingo-sub-2467793%22%20slang%3D%22en-US%22%3Eset-mailbox%20script%2C%20Reply%20To%20email%20address%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2467793%22%20slang%3D%22en-US%22%3E%3CP%3EHey%20Team%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20a%20request%20to%20accomplish%20the%20following.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3COL%20class%3D%22lia-list-style-type-upper-roman%22%3E%3CLI%3ECreate%20several%20hundred%20user%20accounts%20%2C%20license%20them.%26nbsp%3B%3C%2FLI%3E%3CLI%3Eset%20the%20smtp%20address%20on%20each%20of%20the%20users%20mailboxes%3C%2FLI%3E%3CLI%3Elist%20of%20names%20coming%20from%20a%20spreadsheet%26nbsp%3B%3C%2FLI%3E%3C%2FOL%3E%3CP%3EI%20have%20successfully%20taken%20care%20of%20the%201st%20step%20using%20this%20command%3A%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%24Importlist%20%3D%20Import-CSV%20Testlist.csv%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eforeach%20(%24SingleImport%20in%20%24importlist)%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7B%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20New-MsolUser%20-DisplayName%20%24SingleImport.Name%20-Department%20%22Agency%20OWNER%20-%20TSR%22%20-UserPrincipalName%20%24SingleImport.UPN%20-UsageLocation%20US%20-LicenseAssignment%20TenantNameUAT%3ASTANDARDPACK%20-ForceChangePassword%20%24False%3C%2FP%3E%3CP%3E%26nbsp%3B%26nbsp%3B%26nbsp%3B%20%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20first%20part%20works%20as%20stated.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EThis%20part%20however%20does%20not%20work%3A%20%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESet-Mailbox%20-identity%20%24SingleImport.UPN%20-EmailAddresses%20%22SMTP%3A%24SingleImport.Email_id%22%2C%20%22smtp%3A%24SingleImport.UPN%22%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EAll%20i%20want%20to%20do%20with%20the%20above%20command%20is%20to%3A%201)%20Add%20a%20new%20SMTP%20Address%2C%20and%20set%20the%20new%20address%20as%20reply-to.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EError%20Text%3A%3C%2FSTRONG%3E%20Cannot%20process%20argument%20transformation%20on%20parameter%20'EmailAddresses'.%20Cannot%20convert%20value%20%22System.Collections.ArrayList%22%20to%20type%20%22Microsoft.Exchange.Data.ProxyAddressCollection%22.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20i%20try%20using%20the%26nbsp%3B%40Add%7BSMTP%3Aaddress%7D%20it%20fails%20with%20the%20error%20stating%20that%20another%20address%20is%20already%20set%20as%20reply.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20just%20cant%20seem%20to%20get%20past%20the%20Array%20Error.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%2C%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERobert%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2467793%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAdmin%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EExchange%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2468344%22%20slang%3D%22en-US%22%3ERe%3A%20set-mailbox%20script%2C%20Reply%20To%20email%20address%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2468344%22%20slang%3D%22en-US%22%3EUse%20the%20-WindowsEmailAddress%20parameter%2C%20it%20will%20set%20the%20address%20you%20specify%20as%20the%20primary%20SMTP%20one%2C%20while%20keeping%20the%20old%20one%20as%20secondary%20alias%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESet-Mailbox%20user%40domain.com%20-WindowsEmailAddress%20new%40domain.com%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2469392%22%20slang%3D%22en-US%22%3ERe%3A%20set-mailbox%20script%2C%20Reply%20To%20email%20address%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2469392%22%20slang%3D%22en-US%22%3EThanks%20Vasil.%20I%20will%20give%20that%20a%20try.%20However%20can%20you%20explain%20why%20i%20got%20that%20error%20message%3F%20I%20would%20really%20like%20to%20understand%20why%20my%20script%20didn't%20work.%3CBR%20%2F%3E%3CBR%20%2F%3EInterestingly%20if%20i%20type%20this%3A%3CBR%20%2F%3E%3CBR%20%2F%3ESet-Mailbox%20-identity%20first.last%40domain.com%20-EmailAddresses%20%22SMTP%3Aemailaddy1%40domain.com%22%2C%20%22smtp%3Aemailaddy1%40domain.com%22%20-%20it%20works.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20just%20can't%20quite%20figure%20out%20why%20i%20get%20this%20error%20message%3A%3CBR%20%2F%3E%3CBR%20%2F%3ECannot%20process%20argument%20transformation%20on%20parameter%20'EmailAddresses'.%20Cannot%20convert%20value%20%22System.Collections.ArrayList%22%20to%20type%20%22Microsoft.Exchange.Data.ProxyAddressCollection%22.%3CBR%20%2F%3E%3CBR%20%2F%3Eor%20what%20the%20error%20message%20really%20means.%20if%20not%20that's%20fine%20too.%20always%20appreciate%20your%20assistance.%3C%2FLINGO-BODY%3E
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. 

 

Thanks, 

 

Robert 

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 user@domain.com -WindowsEmailAddress new@domain.com
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 first.last@domain.com -EmailAddresses "SMTP:emailaddy1@domain.com", "smtp:emailaddy1@domain.com" - 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 (Contributor)
Solution
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)"