Export PowerShell Object Properties Instead of Table-Formatting Internals
A table that looks correct in PowerShell is already presentation output. If that formatting output is passed to Export-Csv, the resulting file can describe the table's internal formatting objects instead of your intended records.
Keep the original query and the malformed CSV while investigating. Start with a harmless small example in PowerShell 7 on Windows, using a working folder where you are authorised to create a new file.
Select data before exporting it
Microsoft explicitly advises against formatting objects before Export-Csv. Use Select-Object to choose properties and reserve Format-Table for a separate screen display.
For example, this exports two properties from a date object into a new file in the current folder:
Get-Date |
Select-Object -Property Day, DayOfWeek |
Export-Csv -Path '.\date-check.csv' -NoTypeInformation -NoClobber
NoClobber prevents an existing file from being overwritten. If that name already exists, inspect it or choose a different output name deliberately rather than adding Force just to silence the error.
The meaningful distinction is the object sent down the pipeline. Replacing Select-Object with Format-Table would send table-formatting objects to Export-Csv. Changing the filename extension or spreadsheet column widths cannot repair that upstream choice.
Inspect the saved data contract
Open the CSV as text first. For this example, the headings should represent Day and DayOfWeek. Compare the row with the source result. Unexpected format-class identifiers indicate that the exported object type still needs investigation.
Then apply the same structure to your real query: obtain records, select the required properties, and export. Decide the destination's delimiter and encoding requirements separately; a structurally correct object pipeline does not decide those requirements for you.
Check the actual row count and a few meaningful identifiers in the finished export. If collecting live process or service information, remember that a later query can legitimately produce different values, so preserve the collection time with the file.
Keep a separate display command when you also need a readable console table. That lets the report retain its intended columns while the screen view can be adjusted without silently changing the exported data.
Sources: Microsoft Export-Csv reference.