Bird
0
0

How can you define a parameter that accepts multiple string values in PowerShell?

hard📝 Application Q9 of 15
PowerShell - Functions
How can you define a parameter that accepts multiple string values in PowerShell?
Aparam([multi]string$Names)
Bparam([array]$Names = string)
Cparam([string]$Names, [string]$MoreNames)
Dparam([string[]]$Names)
Step-by-Step Solution
Solution:
  1. Step 1: Recall array parameter syntax

    PowerShell uses [string[]] to declare an array of strings.
  2. Step 2: Check options for correct array declaration

    param([string[]]$Names) correctly declares a string array parameter; others are invalid or separate parameters.
  3. Final Answer:

    param([string[]]$Names) -> Option D
  4. Quick Check:

    Use [string[]] for multiple string inputs [OK]
Quick Trick: Use [string[]] to accept multiple strings [OK]
Common Mistakes:
  • Using 'multi' keyword
  • Wrong array syntax
  • Declaring multiple separate parameters instead

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes