0

I am trying to write a PowerShell cmdlet which accepts multiple inputs for a single parameter.

For example, I could do the following easily:

Get-CountryList -Group "a" -Category "x"

But I want to do something like this:

Get-CountryList -Groups "a b c d" -Category "x"

(or)

Get-CountryList -Groups "a,b,c,d" -Category "x"

I searched, but I could not find how to do this.

How can I do it?

1 Answer 1

2

You are passing a single string as the parameter, but you should be passing an array of strings:

Get-CountryList -Groups "a" -Category "x"
Get-CountryList -Groups "a","b","c","d" -Category "x"

You can configure this inside the function if you want as well:

Function Get-CountryList {
   Param (
      [String[]]$Groups,
      [String]$Category
   )
   ...
}
Sign up to request clarification or add additional context in comments.

1 Comment

Worked well. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.