0
以下命令作品完美地使用参数值:PowerShell的将不会从一个变量
Set-Mailbox $mailbox -EmailAddresses SMTP:[email protected],[email protected],[email protected]
试图用一个变量崩溃的电子邮件地址,运行相同的命令。
$SMTPAddresses = "SMTP:[email protected],[email protected],[email protected]”
Set-Mailbox $mailbox -EmailAddresses $SMTPAddress
错误:
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
变量是一个字符串顺便说一句。
$SMTPAddresses.GetType()
IsPublic IsSerial Name BaseType
-------- -------- ---- --------
True True String System.Object
任何想法是什么造成这种情况?