Forum Discussion
set-mailbox script, Reply To email address
Hey Team,
I have a request to accomplish the following.
- Create several hundred user accounts , license them.
- set the smtp address on each of the users mailboxes
- 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
- 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)"
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- Robert BollingerBrass ContributorThanks 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.- 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)"