Bird
0
0

Given the CSV file users.csv with content:

medium📝 Command Output Q13 of 15
PowerShell - File and Directory Operations
Given the CSV file users.csv with content:
Name,Age
Alice,30
Bob,25

What will the following PowerShell command output?
Import-Csv users.csv | Where-Object { $_.Age -gt 27 } | Select-Object -ExpandProperty Name
ANo output
BBob
CAlice`nBob
DAlice
Step-by-Step Solution
Solution:
  1. Step 1: Import and filter CSV data

    The command imports the CSV, then filters rows where Age > 27. Alice's age is 30, Bob's is 25, so only Alice passes.
  2. Step 2: Select and output the Name property

    Select-Object -ExpandProperty Name outputs the Name value directly, so output is 'Alice'.
  3. Final Answer:

    Alice -> Option D
  4. Quick Check:

    Filter Age > 27 = Alice [OK]
Quick Trick: Filter with Where-Object, then expand property for direct output [OK]
Common Mistakes:
  • Confusing string output with array output
  • Using -ExpandProperty incorrectly
  • Assuming both names print without filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes