Click here to Skip to main content
11,803,019 members (83,110 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 KrunalRohit 356
1 OriginalGriff 335
2 CPallini 270
3 F-ES Sitecore 270
4 Sergey Alexandrovich Kryukov 234
0 OriginalGriff 2,950
1 Maciej Los 1,910
2 KrunalRohit 1,862
3 CPallini 1,735
4 Richard MacCutchan 1,157

Advertise | Privacy | Mobile
Web02 | 2.8.151002.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