Click here to Skip to main content
11,704,768 members (46,666 online)
Rate this: bad
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, -identity –AutomateProcessing AutoUpdate

I know my code connection works but it's the "–ResourceDelegates," I don't know how to pass, shown below:

Sample part of the code is here:

command.AddParameter("ResourceDelegates", ",");
command.AddParameter("-Identity", "");
command.AddParameter("-AutomateProcessing", "AutoUpdate");
Posted 18-Nov-10 8:40am
Edited 18-Nov-10 15:29pm
Rate this: bad
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 @(, -identity –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:, | Set-CalendarProcessing -identity –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.

Espen Harlinn at 30-Dec-12 8:18am
Sergey Alexandrovich Kryukov at 30-Dec-12 11:48am
Thank you, Espen.
Rate this: bad
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 "," -identity –AutomateProcessing AutoUpdate

It's a thought, but entirely untested.

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

  Print Answers RSS
0 Sergey Alexandrovich Kryukov 658
1 OriginalGriff 485
2 Andy Lanng 275
3 CPallini 242
4 Maciej Los 225
0 OriginalGriff 8,864
1 Sergey Alexandrovich Kryukov 8,245
2 CPallini 5,189
3 Maciej Los 4,726
4 Mika Wendelius 3,606

Advertise | Privacy | Mobile
Web01 | 2.8.150819.1 | Last Updated 30 Dec 2012
Copyright © CodeProject, 1999-2015
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