PowerShell Format-Table and Format-List: Display Data Clearly

PowerShell Format-Table and Format-List: Display Data Clearly

PowerShell Tips Editor 2 min read
PowerShell Format-Table and Format-List: Display Data Clearly

PowerShell truncates long property values, hides columns, and sometimes outputs data in formats that are hard to read. PowerShell Format-Table Format-List commands give you full control over how objects display in the console. Understanding how and when to use each — and critically, why they must come last in any pipeline — prevents one of the most common PowerShell mistakes.

Quick Answer / TL;DR

Use Format-Table for compact columnar display and Format-List for detailed single-object views. Always put Format-* commands last in a pipeline — piping their output to Export-Csv or other processing cmdlets turns your objects into format strings.

Format-Table Basic Usage

Format-Table (alias ft) displays objects as rows in a table with property names as column headers. Without arguments, it picks the most relevant properties automatically based on the type’s default display definition. Specify properties explicitly to control exactly which columns appear.

# Default columns (type-defined)
Get-Process | Format-Table

# Specify exact columns
Get-Process | Format-Table Name, Id, CPU, WorkingSet -AutoSize
Name          Id    CPU WorkingSet
----          --    --- ----------
chrome      1234 234.5  452363264
pwsh        5678   1.2   87654321

-AutoSize for Dynamic Column Width

-AutoSize measures all values before rendering and sizes columns to fit the widest value rather than using fixed widths. This prevents premature truncation but requires buffering all objects before display, so output does not appear until all objects are collected. For large result sets, this adds a noticeable delay before output starts.

# Without AutoSize: columns use fixed widths, values may truncate
Get-Service | Format-Table Name, DisplayName, Status

# With AutoSize: columns fit the actual data
Get-Service | Format-Table Name, DisplayName, Status -AutoSize

-Wrap for Long Values

Even with -AutoSize, PowerShell caps column width at the terminal width and truncates remaining characters with ellipsis (...). Add -Wrap to allow column values to wrap onto the next line instead of being cut off. This is essential when displaying long paths, descriptions, or messages.

# Long descriptions truncate without -Wrap
Get-EventLog -LogName Application -Newest 5 |
    Format-Table TimeGenerated, EntryType, Message -AutoSize

# -Wrap preserves full values
Get-EventLog -LogName Application -Newest 5 |
    Format-Table TimeGenerated, EntryType, Message -AutoSize -Wrap

Custom Columns with Calculated Expressions

Add calculated columns using a hashtable with Name/Label and Expression keys. The Expression is a script block that receives the current object via $_. This is how you display computed values or rename columns without creating new objects.

# Custom column with calculated value
Get-ChildItem C:\Logs -Filter *.log |
    Format-Table Name,
        @{Label='Size (KB)'; Expression={ [math]::Round($_.Length / 1KB, 1) }},
        @{Label='Modified'; Expression={ $_.LastWriteTime.ToString('yyyy-MM-dd') }},
        @{Label='Age (days)'; Expression={ ((Get-Date) - $_.LastWriteTime).Days }} `
        -AutoSize

Format-List for Detailed Single Objects

Format-List (alias fl) displays each property on its own line, making it ideal for a single object with many properties. Use it when you need to see all properties without column truncation. The wildcard * displays every property on the object, which is useful for discovery.

"# All properties of a single process
Get-Process -Name 'pwsh' | Format-List *

# Specific properties in list format
Get-ADUser -Identity 'jsmith' -Properties * |
    Format-List DisplayName, EmailAddress, Department, Manager, LastLogonDate, Enabled

# Compare two services side by side
Get-Service W3SVC, WAS | Format-List Name, Status, StartType, DependentServices

Why Format-* Must Come Last

The most important rule: Format-* commands convert objects into formatting instructions for the console renderer. After Format-Table, your pipeline contains FormatStartData, FormatEntryData, and FormatEndData objects — not your original data. Piping these to Export-Csv, Where-Object, or any processing cmdlet produces garbage output or errors.

# WRONG: Format-Table before Export-Csv creates format object CSV
Get-Process | Format-Table Name, CPU | Export-Csv C:\Out.csv    # Bad!

# CORRECT: Export-Csv uses original objects, Format-Table for display only
Get-Process | Export-Csv C:\Out.csv -NoTypeInformation           # Save data
Get-Process | Format-Table Name, CPU -AutoSize                   # Display only

# WRONG: piping Format-List output to Where-Object
Get-Service | Format-List * | Where-Object Name -eq 'W3SVC'     # Bad!

# CORRECT: Filter first, then format for display
Get-Service | Where-Object Name -eq 'W3SVC' | Format-List *

Common Errors and Fixes

  • Using Format-Table before Export-Csv converts objects to strings. The exported CSV contains column headers like ClassId2e4f51ef21dd47e99d3c952918aff9cd and format data strings instead of property values. Always pipe to Export-Csv directly, then use Format-Table only in a separate statement for display.
  • -AutoSize still truncates — use -Wrap for complete values. -AutoSize prevents column size from being too small, but it still caps at the terminal width. A 500-character description still truncates in an 80-column terminal with -AutoSize alone. Add -Wrap to ensure no data is cut off.

Related Cmdlets / See Also

Wrapping Up

Use Format-Table for compact multi-object views and Format-List for detailed single-object inspection. Add -AutoSize to fit data and -Wrap to prevent truncation. Always place Format-* commands at the very end of the pipeline — they are for display only, never for data processing.

Send-Item -To