PowerShell Genie

Format-Table

Use Format-Table to render objects as a table of columns for display.

Command 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn — Format-Table

Syntax

1PS> Format-Table [[-Property] <object[]>] [-AutoSize] [-Wrap] [-GroupBy <Object>] [-HideTableHeaders] [<CommonParameters>]
See the command anatomy

Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

Format-Table [[-Property] <object[]>] [-AutoSize] [-Wrap] [-GroupBy <Object>] [-HideTableHeaders] [<CommonParameters>]
  1. Stage 1Format-Table-Property -AutoSize -Wrap -GroupBy -HideTableHeaders

    Try it

    Windows PowerShell

    PowerShell example · browser support is limited.

    Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.

    Interactive simulation · fictional data

    Examples

    Select first 5

    1PS> Get-Service | Select-Object -First 5 | Format-Table Name, Status -AutoSize
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Status   Name      DisplayName
    -------  --------  ---------------------------------------
    Running  BITS      Background Intelligent Transfer Service
    Running  Dnscache  DNS Client
    Stopped  Spooler   Print Spooler
    Running  WinRM     Windows Remote Management

    Select first 6

    1PS> Get-Process | Select-Object -First 6 | Format-Table Name, Id -GroupBy Company
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Name    Id     CPU(s)  WS(MB)
    ------  -----  ------  ------
    chrome  9184   842.31  464.0
    Code    6620   512.08  325.8
    pwsh    11268  18.27   75.0

    Select first 3

    1PS> Get-Service | Select-Object -First 3 | Format-Table Name, DisplayName -Wrap
    Show reference output

    Sample output · fictional data, shaped like the real thing

    Status   Name      DisplayName
    -------  --------  ---------------------------------------
    Running  BITS      Background Intelligent Transfer Service
    Running  Dnscache  DNS Client
    Stopped  Spooler   Print Spooler

    Parameters

    Parameter definitions:

    • -Property
    • -AutoSize
    • -Wrap
    • -GroupBy
    • -HideTableHeaders

    Format-Table on Microsoft Learn

    Practical use and troubleshooting

    Practical scenario: Use Format-Table when you need to render objects as a table of columns for display. Review syntax and sample output, then try an example in the browser lab. Start with one identified target and inspect the returned values before extending the operation to a list. Keep the identity in your report so you can trace each result back to the object or path that produced it.

    Common error and fix: Missing displayed columns can be a width issue rather than missing data. Select the required properties explicitly and inspect one object with Format-List before changing the source query. In an unattended script, capture this failure with its original error record and record which target failed. An empty result and an unsuccessful query must remain distinguishable in the final report.

    See also: Format-List. Format-Table lays out columns; Format-List lays out properties vertically. Both create formatting instructions rather than the original objects needed by filtering and structured export. Read the linked command before substituting it; similar names do not imply identical inputs or output.

    Format-Table reference on Microsoft Learn

    Recap

    Format-Table Use Format-Table to render objects as a table of columns for display.

    Next: Format-List
    Genie guideFormat-Table

    Use Format-Table to render objects as a table of columns for display. The console below is pre-loaded — run it, then change a value and run it again.