Reputation: 775
I am trying to pass a list of strings as a parameter to powershell script. That list may contain any number of argument varies every time. How do I pass this list as a one parameter to powershell script from C#?
Upvotes: 0
Views: 371
Reputation: 470
PowerShell parameters are separated by commas. Just add the parameters comma separated behind the call.
Edit after comment:
Is it maybe possible to change the List<string>
to a StringBuilder
and after each add just add an additional ,?
If that is not possible try it like: List of strings to one string
StringBuilder builder = new StringBuilder();
los.ForEach(s => builder.Append(s+","));
Upvotes: 1