Bird
0
0

Identify the error in this PowerShell function definition:

medium📝 Debug Q14 of 15
PowerShell - Functions
Identify the error in this PowerShell function definition:
function Show-Info {
param([string]$info =)
Write-Output $info
}
AMissing default value after =
BParameter type [string] is invalid
CWrite-Output cannot be used inside functions
DFunction name cannot contain a hyphen
Step-by-Step Solution
Solution:
  1. Step 1: Check parameter default syntax

    The parameter $info has an equals sign but no value after it, which is invalid.
  2. Step 2: Validate other parts

    Parameter type [string] is valid, Write-Output is allowed, and hyphens are allowed in function names.
  3. Final Answer:

    Missing default value after = -> Option A
  4. Quick Check:

    Default value must follow = [OK]
Quick Trick: Default values must not be empty after = [OK]
Common Mistakes:
  • Leaving = without a value
  • Misunderstanding function name rules
  • Thinking Write-Output is disallowed

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes