简体   繁体   中英

c# Powershell exchange multi valued cmd parameter passing

I want to run the following in ac# 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");

Thanks Steve

Try this instead:

command.AddParameter("ResourceDelegates", new string[] { "a@b.c", "b@d.f" });

Ergo, do not prefix the parameter name with a hyphen and pass an array if you need multiple arguments for the parameter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM