Export PowerShell CSV: Using the Export-Csv Cmdlet

The Export-Csv cmdlet converts PowerShell objects into a comma-separated values file, and it’s one of the most commonly used cmdlets for turning script output into something you can open in Excel or hand off to someone else. Basic Usage Get-Process | Select-Object Name, Id, CPU | Sort-Object CPU -Descending | Export-Csv -Path "C:\Reports\processes.csv" -NoTypeInformation This […]

Export Powershell To CSV
The Export-Csv cmdlet converts PowerShell objects into a comma-separated values file, and it’s one of the most commonly used cmdlets for turning script output into something you can open in Excel or hand off to someone else.

Basic Usage

Get-Process | Select-Object Name, Id, CPU | Sort-Object CPU -Descending | Export-Csv -Path "C:\Reports\processes.csv" -NoTypeInformation
This gets every running process, selects just the Name, Id, and CPU columns, sorts by CPU usage descending, and writes the result to a CSV file.

Useful Parameters

  • -NoTypeInformation — omits the “#TYPE” header line that PowerShell adds by default, which most other tools (including Excel) don’t expect.
  • -Append — adds rows to an existing CSV instead of overwriting it, useful when a script runs on a schedule and you want a running log.
  • -Delimiter ";" — some regional Excel settings expect semicolons instead of commas.
  • -Encoding UTF8 — worth setting explicitly if your data includes non-ASCII characters (accented names, currency symbols, non-English text); without it, older PowerShell versions can default to an encoding that mangles those characters when the file is reopened.
  • -Force — overwrites a read-only file at the target path instead of failing with an access-denied error, useful in scheduled scripts writing to the same filename each run.
To read a CSV back into PowerShell as objects, use the matching Import-Csv -Path "C:\Reports\processes.csv" cmdlet.

A Common Gotcha: Nested Objects

If a property you select holds a complex object rather than a simple value (for example, a group membership list or a nested settings object), Export-Csv doesn’t flatten it — it just writes the object’s type name (like System.Object[]) into the cell instead of anything useful. Convert those properties to a plain string first, typically with -join, before piping to Export-Csv:
Get-ADUser -Filter * -Properties MemberOf | Select-Object Name, @{Name='Groups';Expression={$_.MemberOf -join '; '}} | Export-Csv -Path "C:\Reports\users.csv" -NoTypeInformation
That calculated property joins the group list into a single readable string per row instead of a broken type-name placeholder.

Resources


Discover more from TechyGeeksHome

Subscribe to get the latest posts sent to your email.

Andrew Armstrong

Andrew Armstrong is a UK-based IT professional with 26+ years of hands-on experience in Windows, Windows Server, SCCM/ConfigMgr, Active Directory, PowerShell, and enterprise infrastructure.

He founded TechyGeeksHome in 2010 and has published over 1,500 practical guides covering real-world IT problems and solutions. When not solving IT problems,

Andrew develops free Windows utilities including Ultimate Settings Panel, which has been downloaded over 850,000 times.