Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

CSV · PowerShell Automation

Direct answer

PowerShell handles CSV with Import-Csv, which turns rows into objects with properties from the header, and Export-Csv -NoTypeInformation for reports.

When to use this

Use this when PowerShell reads or writes CSV.

First 30 seconds

1. Import-Csv returns objects per row.

2. Specify delimiter and encoding.

3. Validate columns and values.

4. Export-Csv -NoTypeInformation.

5. Excel locale quirks (semicolon).

Operational verification

CSV → Import-Csv → objects → validation

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
PowerShell 7.5/current
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformPowerShell 7.5/current · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when PowerShell reads or writes CSV.
What next?3 suggested next steps
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Verification path Verify boundary

Export a small fixture containing delimiters, quotes, empty values and non-ASCII text, then import it and compare required field names/counts and converted values. Check the raw header line when interoperability matters. For large data, validate row counts and rejected records rather than trusting only command completion.

Step 2 Common mistakes Narrow the fault
  • Encoding problems with Export-Csv (set -Encoding utf8).
Step 3 Where it fails Narrow the fault

CSV is a lossy serialization boundary for rich PowerShell objects. Export success does not show the receiving system parsed every row or preserved types. Keep object projection, text serialization, transport/storage and downstream import validation as separate steps.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Key points
  • Import-Csv returns objects with header names as properties.
  • Export-Csv -NoTypeInformation writes clean files.
  • Set -Delimiter and -Encoding explicitly.
Key checks
  • Import-Csv f.csv -Delimiter ';' — import
  • Export-Csv out.csv -NoTypeInformation -Encoding utf8 — export
  • Required columns validation — input checks
ReferenceWhy it matters1 section · depth on demand

Worked example

Import-Csv and Export-Csv turn CSV files into objects and back, which makes bulk operations — creating users, updating devices, generating reports — straightforward.

Worked example: bulk-create AD users from HR data, validating each row and reporting results.

$results = Import-Csv .\new-users.csv -Delimiter ';' | ForEach-Object {
  try {
    if ($_.SamAccountName -notmatch '^[a-z]{3,20}$') { throw "invalid username" }
    New-ADUser -Name $_.Name -SamAccountName $_.SamAccountName -Path $_.OU -Enabled $false -ErrorAction Stop
    [pscustomobject]@{ User = $_.SamAccountName; Result = 'Created' }
  } catch {
    [pscustomobject]@{ User = $_.SamAccountName; Result = "Failed: $($_.Exception.Message)" }
  }
}
$results | Export-Csv .\new-users-result.csv -NoTypeInformation -Encoding utf8

All imported values are strings — convert numbers and dates explicitly — and match the delimiter and encoding of files produced by Excel in your locale.

ReferenceImportant terms & boundaries1 section · depth on demand

PowerShell mechanics

Import-Csv maps header fields to object properties and Export-Csv serializes object property values into delimited text. CSV has no native PowerShell type/method metadata, so imported fields are generally textual representations that require deliberate conversion. Export property shape is driven by the objects presented to the cmdlet; formatting objects from Format-* are not the original data contract.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Authoring and lifecycle

Define headers, delimiter/culture, encoding and quoting expectations for the consumer. Project a stable property set before export and convert typed values explicitly on import when arithmetic/date/boolean semantics matter. Never pipe Format-Table or other formatting commands into Export-Csv; formatting belongs only at the final human-display boundary.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docPowerShell 7.5/current 7.5/current

Microsoft Learn documentation reviewed for bounded PowerShell reference claims. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/export-csv?view=powershell-7.5 · confidence 94%
Embedded reference data

Quick lookup tables

CSV · PowerShell operational reference

Topic-specific PowerShell runtime identity, persistence, verification, output and failure-boundary lookup.

BoundaryCSV reference
Runtime identityPowerShell edition/version + command/module source
Persistent intentScript/module/config prerequisites under source control
VerificationRead-only discovery → execution evidence → independent target read-back
Output contractStructured objects/streams before formatting
Failure boundarySeparate engine/binding from transport/API/native and target-state failures
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

A CSV that opens nicely in a spreadsheet can still violate the expected delimiter, encoding or schema. Imported numbers/dates may be strings until converted, and locale-specific formatting can silently change interpretation. Screen tables are not evidence of the raw CSV contract.

Confirmation

Confirm action

Continue?