Bird
0
0

Which PowerShell command correctly saves the contents of the variable $results to a CSV file named data.csv?

easy📝 Syntax Q3 of 15
PowerShell - Automation Patterns
Which PowerShell command correctly saves the contents of the variable $results to a CSV file named data.csv?
AExport-Csv -InputObject $results -FileName 'data.csv'
B$results | Export-Csv -Path 'data.csv' -NoTypeInformation
CSave-Csv -Input $results -Path 'data.csv'
DOut-File -InputObject $results -FilePath 'data.csv'
Step-by-Step Solution
Solution:
  1. Step 1: Identify correct cmdlet

    Export-Csv is used to export objects to CSV files.
  2. Step 2: Use correct parameters

    -Path specifies the output file; -NoTypeInformation omits type info.
  3. Final Answer:

    $results | Export-Csv -Path 'data.csv' -NoTypeInformation -> Option B
  4. Quick Check:

    Export-Csv with -Path and -NoTypeInformation [OK]
Quick Trick: Use Export-Csv with -Path to save objects [OK]
Common Mistakes:
  • Using incorrect cmdlets like Save-Csv or Out-File for CSV export
  • Omitting -NoTypeInformation leading to extra type lines

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes