Bird
0
0

What will be the output of this command?

medium📝 Command Output Q5 of 15
PowerShell - Remote Management
What will be the output of this command?
Invoke-Command -ComputerName localhost -ScriptBlock { Get-Date -Format 'yyyy' }
ACurrent year as a 4-digit number
BFull date and time string
CError: Invalid format string
DNothing, command runs silently
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the script block

    The script block runs Get-Date -Format 'yyyy' which returns the current year as 4 digits.
  2. Step 2: Confirm output type

    The output is the current year like '2024', not full date or error.
  3. Final Answer:

    Current year as a 4-digit number -> Option A
  4. Quick Check:

    Get-Date with 'yyyy' format returns year [OK]
Quick Trick: Get-Date -Format 'yyyy' returns current year [OK]
Common Mistakes:
  • Expecting full date/time output
  • Assuming format string causes error
  • Thinking command produces no output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes