Click here to Skip to main content
12,621,302 members (32,186 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# 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

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 18-Nov-10 9:40am
Updated 18-Nov-10 16:29pm
v2
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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

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
  Permalink  
v3
Comments
Espen Harlinn 30-Dec-12 8:18am
   
5'ed!
Sergey Alexandrovich Kryukov 30-Dec-12 11:48am
   
Thank you, Espen.
—SA
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161128.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100