0

以下は私が使用しているコードです。powershell Emailaddresses パラメータを使用して複数のアドレスを追加できません。1 つの電子メール アドレスを入力するだけでコードは正常に動作しますが、以下のコードに 2 つのアドレスを追加すると、無効な smtp アドレスを示す例外が返されます。

PSCredential credential = new PSCredential(username, password);
WSManConnectionInfo connectionInfo = new WSManConnectionInfo((new Uri(liveIdconnectionUri)), "http://schemas.microsoft.com/powershell/Microsoft.Exchange", credential);
connectionInfo.AuthenticationMechanism = AuthenticationMechanism.Default;

Runspace runspace = System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(connectionInfo);
PowerShell powershell = PowerShell.Create();
runspace.Open();
powershell.Runspace = runspace;

var secure = new SecureString();
foreach (char c in textBox5.Text)
{
    secure.AppendChar(c);
}

PSCommand command2 = new PSCommand();
command2.AddCommand("Set-Mailbox");
command2.AddParameter("Identity", "lferrigno");
command2.AddParameter("EmailAddressPolicyEnabled", 0);
command2.AddParameter("EmailAddresses", "SMTP:lferrigno@sscincorporated.com,lou.ferrigno@altegrahealth.com");

powershell.Commands = command2;
powershell.Invoke();
4

2 に答える 2