Bird
0
0

Consider this script:

medium📝 Command Output Q5 of 15
PowerShell - Functions
Consider this script:
param([string]$User = "Guest")
Write-Output "Welcome, $User!"
What will be the output if the script is run without any parameters?
AWelcome, Guest!
BWelcome, !
CWelcome, $User!
DError: Missing parameter User
Step-by-Step Solution
Solution:
  1. Step 1: Check default value

    The parameter $User has a default value of "Guest".
  2. Step 2: Running without parameters

    Since no value is passed, the default "Guest" is used.
  3. Step 3: Output

    The script outputs "Welcome, Guest!".
  4. Final Answer:

    Welcome, Guest! -> Option A
  5. Quick Check:

    Default parameter values are used if none provided [OK]
Quick Trick: Default parameter values are used when no input given [OK]
Common Mistakes:
  • Assuming parameters are mandatory by default
  • Expecting an error without input
  • Confusing variable names with literal strings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes