Format-List

Format output as a list of object properties, each on a new line.

Syntax
       Format-List [[-Property] Object[]]  [-view string]
          [-groupBy Object] [-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.

   -view string
       The name of an alternate format or "view."
       The DotNetTypes.format.ps1xml formatting file defines these views.
       You cannot use -Property and -View in the same command.

   -groupBy Object
       Format the output in groups based on a shared property or value.

   -force 
       Override restrictions that prevent the command from succeeding, 
       without compromising security. Force will override read-only
       attributes but will not change file permissions.

   -inputObject psobject
       The objects to format. A variable, command or expression that gets the objects.
       Use for flat collections, nested collections may need to be unwrapped and passed through the pipe.

   -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
       The common parameters: -Verbose, -Debug,-ErrorAction, -ErrorVariable, -OutVariable.

Standard Aliases for Format-List: fl

The format- cmdlets emit specialized formatting directives, so they do not ouptut a standard PowerShell object, for this reason they should in the pipeline after (to the right) of any WHERE filter.

Format-Custom 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

Custom display formats can also be defined using XML tags see get-help about_Display.xml for details.

Examples

Print a list of running processes, incuding the process name and path:

PS C:\> Get-Process | Format-List -property name, path

Print a list of running processes, incuding all the properties:

PS C:\> Get-Process | Format-List -property *

Print the objects stored in $My_Variable in list format:

PS C:\> Format-List -InputObject $My_Variable

“Knowledge is a process of piling up facts; wisdom lies in their simplification” ~ Martin Fischer

Related PowerShell Cmdlets

format-custom - Format output using a customized view.
format-table - Format the output as a table.
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.


 
Copyright © 1999-2024 SS64.com
Some rights reserved