c#Powershell交换多值cmd参数传递

时间:2010-11-18 19:29:16

标签: c# powershell exchange-server

我想在c#循环中运行以下内容,但我不知道如何使用逗号传递参数的多值。实际的cmdlet将在下面并且在交换PowerShell中起作用:

Set-CalendarProcessing -ResourceDelegates jonDoe @ test.com,johnnydoe @ test.com -identity testroom@test.com -AutomateProcessing AutoUpdate

我知道我的代码连接有效,但它是“-ResourceDelegates jonDoe @ test.com,johnnydoe @ test.com”我不知道如何通过,如下所示:

代码的示例部分在这里:

command.AddCommand("Set-CalendarProcessing");
command.AddParameter("-ResourceDelegates", "userA@test.com,userB@test.com");
command.AddParameter("-Identity", "test@test.com");
command.AddParameter("-AutomateProcessing", "AutoUpdate");

由于 史蒂夫

1 个答案:

答案 0 :(得分:2)

请改为尝试:

command.AddParameter("ResourceDelegates", new string[] { "a@b.c", "b@d.f" });

如果您需要参数的多个参数,请使用连字符为前缀参数名称并传递数组。