Format output as a table.
Syntax Format-Table [[-property] Object[]] [-autosize] [-hideTableHeaders] [-groupBy Object] [-wrap] [-view string] [-force] [-inputObject psobject] [-expand string] [-displayError] [-showError] [CommonParameters] Key: -property Object[] The object properties to display (in order) Wildcards are permitted. You cannot use -Property and -View in the same command. -autosize Adjust the column sizes based on the width of the data. Ignore any column details in the view. -hideTableHeaders Omit column headings from the table. -view string The name of an alternate format or "view." -groupBy Object Format the output in groups based on a shared property or value. -wrap Display text that exceeds the column width on the next line. By default, text that exceeds the column width is truncated. -force Directs the cmdlet to display all of the error information. Use with -DisplayError or -ShowError.
By default, when an error object is written to the error or display streams, only some of the error information is displayed. -inputObject psobject The objects to format. A variable, command or expression that gets the objects. -expand string Where string is either "EnumOnly" (the default), "CoreOnly" or "Both" "CoreOnly" will format and display properties of the collection object itself, while "emumOnly" will enumerate and display the object properties. (designed around the ICollection (System.Collections) interface.) -displayError Display errors at the command line. -showError Send errors through the pipeline. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Standard Aliases for Format-Table: ft
The value of -GroupBy or -Property can be a new calculated property. To create a calculated property, use a hash table. Valid keys are:
Name (or Label) string
Expression string or script block
FormatString string
Width int32 -Property only
Alignment -Property only ("Left", "Center", or "Right")
In addition to simply formatting output as a table, Format-Table can be used to add calculated properties to an object before displaying it.
To add calculated properties, use the Property parameter to specify a hash table. The hash table must include two keys: Label and Expression. The Label key is assigned the name of the calculated property. The Expression key is assigned a script block that is evaluated to determine the value of the property.
Custom display formats can also be defined using XML tags see get-help about_Display.xml for details.
Examples
Print information about Windows PowerShell snap-ins in a table:
PS C:\> get-pssnapin | format-table -wrap
Print a list of running processes formatted into groups with the same base priority class:
PS C:\> get-process | format-table -groupby basepriority
Print the winlogon process, including a calculated total running time:
PS C:\> get-process winlogon | format-table ProcessName, @{Label="DD.HH:MM:Seconds"; Expression={(get-date) - $_.StartTime}}
Changing the above for the notepad process, notice that this this will add up the running time for ALL notepad processes currently running:
PS C:\> get-process notepad | format-table ProcessName, `
@{Label="DD.HH:MM:Seconds"; Expression={(get-date) - $_.StartTime}}
“A lot of people are afraid to say what they want, thats why a lot of people don't get what they want” ~ Madonna
Related PowerShell Cmdlets:
format-custom - Format output using a customized view.
format-list - Format output as a list of properties, each on a new line.
format-wide - Format objects as a table of their properties.
out-file - Send command output to a file.
out-host - Send the pipelined output to the host.