The following command works perfectly:
Set-Mailbox $mailbox -EmailAddresses SMTP:[email protected],[email protected],[email protected]
Trying to run the same command with the email addresses in a variable crashes.
$SMTPAddresses = "SMTP:[email protected],[email protected],[email protected]”
Set-Mailbox $mailbox -EmailAddresses $SMTPAddress
Error:
Set-Mailbox : Cannot convert 'SMTP:[email protected],[email protected],[email protected]' to the type 'Microsoft.Exchange.Data.ProxyAddressCollection' required by parameter 'EmailAddresses'. The address 'SMTP:[email protected],[email protected],[email protected]' is invalid: The address '[email protected],[email protected],[email protected]' is not a valid SMTP address.
At line:1 char:39
+ Set-Mailbox $mailbox -EmailAddresses $SMTPAddresses
+ ~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-Mailbox], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgument,Microsoft.Exchange.Management.RecipientTasks.SetMailbox
The variable is a string btw.
$SMTPAddresses.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
Any ideas what is causing this?