powershell – Use a function with unknown number of variables and other parameters

Question:

I need to create a function.
First variable must be an array with an unknown number of parameters plus another variable.
My problem is that I don’t know how distinguish between them.

I post an example:

The result of this function is

but as you can see I loop array elements and concatenate them. I thought to get just

Where is my mistake?

Answer:

The way you call it is:

You don’t use “,” as a parameter seperator in PowerShell. It is just a space. The moment you put a “,” it becomes a single parameter.

Source:

powershell – Use a function with unknown number of variables and other parameters by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply