For example, in the MyFunction function, I create a parameter called Path and set the default value to "c:\ps-test".
function MyFunction
{
param ($path = "c:\ps-test")
...
}
But what if the default value can be more than one item? What if you can set two paths, or three names, or 10 languages as the default?
To create a parameter with more than one default value, you need to explicitly format the default value as an array "@( )" . Be sure to separate the values with commas, too.
For example, in the MyFunction function, I create a parameter called Path and set the default values to "c:\ps-test" and "c:\users\juneb".
function MyFunction
{
param ($path = @("c:\ps-test", "c:\users\juneb"))
...
}
Just to be explicit, I always show the data type in the variable, so that it shows up in the help topic for the function. To show multiple values (an array), add a pair of square brackets after the type name.
For example, the path parameter takes more than one string.
function MyFunction
{
param ([string[]]$path = @("c:\ps-test", "c:\users\juneb"))
...
}
Hope this helps!
-- juneb