Click here to Skip to main content
15,867,568 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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


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");
Posted
Updated 18-Nov-10 15:29pm
v2

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
C#
Set-CalendarProcessing –ResourceDelegates @(jonDoe@test.com,johnnydoe@test.com) -identity testroom@test.com –AutomateProcessing AutoUpdate


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)], you could use it like this:
jonDoe@test.com,johnnydoe@test.com | Set-CalendarProcessing -identity testroom@test.com –AutomateProcessing AutoUpdate


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
 
Share this answer
 
v3
Comments
Espen Harlinn 30-Dec-12 8:18am    
5'ed!
Sergey Alexandrovich Kryukov 30-Dec-12 11:48am    
Thank you, Espen.
—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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900