Export-Csv output looks wrong
Documentation: Microsoft Learn
Work the problem
The CSV contains internal names
Fictional case: A report uses Get-Service | Format-Table Name,Status | Export-Csv. The resulting headers include formatting metadata.
Reasoning notebook
Record the evidence that supports your answer and the check you would run next. Your notes stay in this browser — nothing is uploaded.
Why it happens
Format-Table and its siblings replace real objects with formatting instruction objects, and Export-Csv faithfully serializes those instructions rather than the data. Out-String has a comparable effect by collapsing everything into one string. It looked right in the console because the console is where formatting was meant to be the last step.
Check this first
What to look for
Select-Object creates data objects with those properties. Format-Table creates display instructions that should not be exported as records.
Object flow
Where did the CSV become garbage?
Genie: find the stage where data objects stop being data objects.
Bad
Good
Working through it
- Remove any Format-Table, Format-List, or Out-String sitting between the data and Export-Csv.
- Choose columns with Select-Object instead, since that emits objects rather than formatting directives.
- Add -NoTypeInformation on Windows PowerShell to drop the type comment from the first line.
- Pipe into Get-Member when unsure and check that the type name is not one of the Format types.
- Flatten any array-valued property through a calculated property that joins it, or the column receives a type name.
Avoiding it next time
Verify the repair: Import the new CSV and confirm Name and Status are the properties, then compare the row count with the intended service set.
Primary documentation
Work through the incident
Repair a service CSV
A service export contains formatting metadata instead of the columns you need.
The sandbox is visible now. Sign in with Google only when you run or check a task; commands and temporary files are discarded when you leave.
Run a command to inspect its result.