Bird
0
0

You want to filter users older than 30 from users.csv and save to older.csv. Which script correctly does this?

hard📝 Application Q8 of 15
PowerShell - File and Directory Operations
You want to filter users older than 30 from users.csv and save to older.csv. Which script correctly does this?
A$users = Import-Csv -Path users.csv $users | Where-Object { [int]$_.'Age' -gt 30 } | Export-Csv -Path older.csv -NoTypeInformation
BImport-Csv users.csv | Export-Csv older.csv -Filter { $_.Age -gt 30 }
CImport-Csv -Path users.csv | Where { $_.Age > 30 } | Export-Csv older.csv
D$users = Import-Csv users.csv $users | Select-Object Age -gt 30 | Export-Csv older.csv
Step-by-Step Solution
Solution:
  1. Step 1: Import CSV and filter by Age

    $users = Import-Csv -Path users.csv $users | Where-Object { [int]$_.'Age' -gt 30 } | Export-Csv -Path older.csv -NoTypeInformation imports users.csv, filters objects where Age > 30 using Where-Object with type cast.
  2. Step 2: Export filtered data without type info

    Filtered objects are exported to older.csv with -NoTypeInformation to omit type header.
  3. Final Answer:

    Option A script correctly filters and exports users older than 30 -> Option A
  4. Quick Check:

    Use Where-Object with condition and Export-Csv [OK]
Quick Trick: Use Where-Object to filter before Export-Csv [OK]
Common Mistakes:
  • Using -Filter parameter on Export-Csv
  • Using Where instead of Where-Object
  • Incorrect Select-Object usage for filtering

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes