Bird
0
0

What will be the output of this PowerShell script?

medium📝 Command Output Q13 of 15
PowerShell - Automation Patterns
What will be the output of this PowerShell script?
Get-Service | Where-Object { $_.Status -eq 'Running' } | Select-Object -First 2 | Export-Csv -Path running.csv -NoTypeInformation; Get-Content running.csv
AEmpty file because no services are running.
BAn error because Export-Csv cannot be piped.
CAll services regardless of status.
DThe first two running services listed in CSV format.
Step-by-Step Solution
Solution:
  1. Step 1: Filter running services and select first two

    The script filters services with Status 'Running' and selects first two.
  2. Step 2: Export to CSV and display content

    Export-Csv saves these two services to running.csv, then Get-Content shows the CSV text.
  3. Final Answer:

    The first two running services listed in CSV format. -> Option D
  4. Quick Check:

    Filter + Export-Csv + Get-Content = The first two running services listed in CSV format. [OK]
Quick Trick: Export-Csv saves objects; Get-Content reads file text [OK]
Common Mistakes:
  • Thinking Export-Csv cannot be piped
  • Assuming all services are output without filtering
  • Believing file will be empty if services run

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes