PowerShell - FunctionsHow 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)Check Answer
Step-by-Step SolutionSolution:Step 1: Recall array parameter syntaxPowerShell uses [string[]] to declare an array of strings.Step 2: Check options for correct array declarationparam([string[]]$Names) correctly declares a string array parameter; others are invalid or separate parameters.Final Answer:param([string[]]$Names) -> Option DQuick Check:Use [string[]] for multiple string inputs [OK]Quick Trick: Use [string[]] to accept multiple strings [OK]Common Mistakes:Using 'multi' keywordWrong array syntaxDeclaring multiple separate parameters instead
Master "Functions" in PowerShell9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallTime
More PowerShell Quizzes Error Handling - Error logging patterns - Quiz 8hard Error Handling - Try-Catch-Finally - Quiz 11easy Error Handling - Error logging patterns - Quiz 13medium Functions - Comment-based help - Quiz 13medium Functions - Advanced functions (CmdletBinding) - Quiz 5medium Modules and Script Organization - Module creation basics - Quiz 10hard Regular Expressions - Why regex enables pattern matching - Quiz 1easy Regular Expressions - Regex with Select-String - Quiz 14medium Regular Expressions - match operator - Quiz 8hard Working with Objects - Adding methods with ScriptMethod - Quiz 10hard