Bird
0
0

What will this script output?

medium📝 Command Output Q5 of 15
PowerShell - Automation Patterns
What will this script output?
$data = Get-Service | Select-Object Name, Status; $data | Export-Csv -Path 'services.csv' -NoTypeInformation; (Import-Csv 'services.csv').Count
AZero because the CSV file is empty
BThe number of services running on the system
CAn error because Import-Csv cannot read the file
DThe total count of all services retrieved
Step-by-Step Solution
Solution:
  1. Step 1: Understand data collection

    Get-Service retrieves all services; Select-Object picks Name and Status.
  2. Step 2: Export and re-import data

    Data is exported to CSV and then imported back; .Count returns number of entries.
  3. Final Answer:

    The total count of all services retrieved -> Option D
  4. Quick Check:

    Import-Csv count = Total services [OK]
Quick Trick: Import-Csv returns array; use .Count for number of entries [OK]
Common Mistakes:
  • Confusing running services count with total services
  • Expecting Import-Csv to fail reading the file
  • Assuming CSV file is empty after export

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes