When would you use Select-Object rather than Format-Table?
Documentation: Microsoft Learn
Choose Select-Object for reusable data and Format-Table for display. Understand why formatting before Export-Csv causes problems.
Interview · Question 6 of 34
Answer before reveal
Your draft
Write the answer you would give in an interview. The model answer stays hidden until you have drafted at least a short response.
A strong answer
Use Select-Object when the next step needs objects containing a chosen set of properties. It can also create calculated properties and limit a result set. The selected output remains suitable for further processing, comparison or export. Use Format-Table when the goal is a human-readable console display.
Formatting commands produce instructions for the formatting system. They do not simply reorder the properties of the original objects. That is why piping Format-Table into Export-Csv can produce formatting metadata instead of a useful report. Select the report columns first, then send those objects directly to Export-Csv.
In an interview, describe two branches from the same underlying data: one exports structured records and the other formats a preview for a person. Keep formatting near the end of a pipeline, and do not let a helper function return display-only output if callers need to reuse its results.
Show it concretely
Expect this follow-up
How would you preserve the objects for export while formatting only the final display?
Primary documentation
Export-Csv reference · Select-Object reference · Get-Process reference