C#powershell多值参数传递 [英] C# powershell multi valued parameter passing

查看:154
本文介绍了C#powershell多值参数传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



I want to run the following in a c# loop but I just don''t know how to pass a multi value for a parameter with a comma. The actual cmdlet would be below and does work in exchange powershell:

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





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



代码的示例部分在这里:





I know my code connection works but it''s the "–ResourceDelegates jonDoe@test.com,johnnydoe@test.com" I don''t know how to pass, shown below:

Sample part of the code is here:

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

推荐答案

答案取决于类型和参数为函数 Set-CalendarProcessing ResourceDelegates 的参数传递选项,特别是,如果参数从管道传递并正确处理。如果我可以假设此参数可以接受值列表,则调用将看起来像

The answer depends on the type and parameter passing options for the parameters of ResourceDelegates of the function Set-CalendarProcessing, in particular, if the parameter passed from the pipeline and processed correctly. If I can assume that this parameter can accept a list of values, the call will look like
Set-CalendarProcessing –ResourceDelegates @(jonDoe@test.com,johnnydoe@test.com) -identity testroom@test.com –AutomateProcessing AutoUpdate





此cmdlet支持或不支持另一个选项,I只是不知道。如果此参数支持列表,并且它还具有属性 [Parameter(ValueFromPipeline =



Another option may or may not be supported by this cmdlet, I just don''t know. If this parameter supports a list and if it also has the attribute [Parameter(ValueFromPipeline =


true)] ,则可以使用它像这样:

true)], you could use it like this:
jonDoe@test.com,johnnydoe@test.com | Set-CalendarProcessing -identity testroom@test.com –AutomateProcessing AutoUpdate





这是我不知道的,你需要检查它。你写这个功能了吗?这不是那么微不足道。要支持列表,该函数必须使用 begin {<#...#>}进程{<#...#>}结束{<#...#> ;} 声明或部分声明;在这种情况下,进程的主体执行的次数与列表的长度一样多。



< dd> -SA



This is something I just don''t know, you need to check it up. Did you write this function? This would be not so trivial. To support a list, the function has to use begin {<# ... #>} process {<# ... #>} end {<# ... #>} statement, or part of it; in this case, the body of process is executed as many times as the length of the list.

—SA


我没有尝试过,但是在参数旁边加上逗号可能有效。

I haven''t tried it, but putting quotes around the parameter with the comma in it may work.
Set-CalendarProcessing –ResourceDelegates "jonDoe@test.com,johnnydoe@test.com" -identity testroom@test.com –AutomateProcessing AutoUpdate





这是一个想法,但完全未经测试。



It''s a thought, but entirely untested.


这篇关于C#powershell多值参数传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆