Bird
0
0

What will be the output of this PowerShell command run on macOS terminal?

medium📝 Command Output Q4 of 15
PowerShell - Cross-Platform PowerShell
What will be the output of this PowerShell command run on macOS terminal?
$date = Get-Date -Format 'yyyy-MM-dd'; Write-Output $date
AError: Get-Date is not recognized
BCurrent date in yyyy-MM-dd format, e.g., 2024-06-15
CThe string 'Get-Date -Format yyyy-MM-dd'
DEmpty output
Step-by-Step Solution
Solution:
  1. Step 1: Understand Get-Date with format

    Get-Date with -Format 'yyyy-MM-dd' returns current date as string in that format.
  2. Step 2: Write-Output prints the date string

    Write-Output outputs the value stored in $date, which is the formatted date string.
  3. Final Answer:

    Current date in yyyy-MM-dd format, e.g., 2024-06-15 -> Option B
  4. Quick Check:

    Get-Date with format outputs formatted date string [OK]
Quick Trick: Get-Date -Format returns formatted date string [OK]
Common Mistakes:
  • Expecting command error
  • Confusing command output with command text
  • Assuming empty output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes