Bird
0
0

Identify the error in this function definition:

medium📝 Debug Q6 of 15
PowerShell - Functions
Identify the error in this function definition:
function GetDate { Write-Output Get-Date }
AGet-Date should be called with parentheses
BWrite-Output should be Write-Host
CMissing parentheses after function name
DFunction name cannot be GetDate
Step-by-Step Solution
Solution:
  1. Step 1: Check function syntax

    Function definition is valid without parentheses if no parameters.
  2. Step 2: Analyze command inside function

    Get-Date is a cmdlet and should be called with parentheses to execute.
  3. Final Answer:

    Get-Date should be called with parentheses -> Option A
  4. Quick Check:

    Cmdlet calls need parentheses = A [OK]
Quick Trick: Call cmdlets with parentheses to execute inside functions [OK]
Common Mistakes:
  • Thinking function needs parentheses without parameters
  • Confusing Write-Output and Write-Host
  • Believing function names are restricted

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes