Commands / Text and objects

Export-Csv

Write objects to a CSV file

beginner Text and objects Aliases epcsv

Export-Csv
 Get-ChildItem -File | Select-Object Name, Length | Export-Csv -Path .\files.csv -NoTypeInformation
Works on
WindowsLinuxmacOS
PowerShell
5.1 and later
Reference
Microsoft Learn: Export-Csv

Writes a CSV. -NoTypeInformation drops the #TYPE header (needed in Windows PowerShell 5.1). In PowerShell 7 that is already the default.

Select the properties you want first. Do not export formatted objects.

Try this

Get-Process | Select-Object -First 5 Name, Id | Export-Csv -Path .\procs.csv -NoTypeInformation

Related commands