0
0
PowerShellscripting~5 mins

CSV operations (Import-Csv, Export-Csv) in PowerShell - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the <code>Import-Csv</code> cmdlet do in PowerShell?
It reads data from a CSV file and converts each row into a PowerShell object, making it easy to work with the data in scripts.
Click to reveal answer
beginner
How does Export-Csv help in PowerShell scripting?
It takes PowerShell objects and saves them as a CSV file, allowing you to export data in a simple, readable format.
Click to reveal answer
intermediate
Why is it important to use the -NoTypeInformation parameter with Export-Csv?
Because it prevents PowerShell from adding extra type information as the first line in the CSV file, keeping the file clean and easier to use with other programs.
Click to reveal answer
beginner
Show a simple PowerShell command to import a CSV file named <code>data.csv</code>.
Import-Csv -Path "data.csv"
This command reads the CSV and outputs objects representing each row.
Click to reveal answer
beginner
How can you export a list of objects stored in a variable $users to a CSV file named users.csv without type info?
$users | Export-Csv -Path "users.csv" -NoTypeInformation
This saves the objects as CSV cleanly.
Click to reveal answer
What does Import-Csv return when it reads a CSV file?
ANothing, it only displays the file
BA list of PowerShell objects representing each row
CA binary file
DA plain text string of the CSV content
Which parameter prevents extra type info from being added when exporting CSV?
A-SkipHeader
B-CleanOutput
C-Raw
D-NoTypeInformation
How do you export objects stored in $data to a CSV file named output.csv?
AImport-Csv -Path output.csv
BExport-Csv -Input $data -File output.csv
C$data | Export-Csv -Path "output.csv" -NoTypeInformation
DSave-Data -File output.csv
What is the default delimiter used by Import-Csv and Export-Csv?
AComma (,)
BSemicolon (;)
CTab (\t)
DPipe (|)
If you want to read a CSV file and filter rows where the 'Age' column is greater than 30, which cmdlet would you use first?
AImport-Csv
BExport-Csv
CGet-Content
DConvertTo-Csv
Explain how you would use PowerShell to read a CSV file, modify some data, and save it back to a new CSV file.
Think about reading, changing, then writing data.
You got /3 concepts.
    Describe why CSV files are useful in scripting and automation tasks.
    Consider how CSV helps move data between tools.
    You got /4 concepts.