CmdID / PowerShell / Cmdlets / Format
Format-List
Formats the output as a list of properties in which each property appears on a new line. PowerShell reference
From the PowerShell reference
8 parameters
Alias fl
What it does
Formats the output as a list of properties in which each property appears on a new line. The Format-List cmdlet formats the output of a command as a list of properties in which each property is displayed on a separate line. You can use Format-List to format and display all or selected properties of an object as a list (Format-List -Property *). Because more space is available for each item in a list than in a table, PowerShell displays more properties of the object in the list, and the property values are less likely to be truncated.
Format-List [[-Property] <Object[]>] [-GroupBy <Object>] [-View <string>] [-ShowError] [-DisplayError] [-Force] [-Expand <string>] [-InputObject <psobject>] [<CommonParameters>]
Format computer services
Get-Service | Format-ListIdentifyFormat PS1XML files
$A = Get-ChildItem $PSHOME\*.ps1xml
Format-List -InputObject $AIdentifyFormat process properties by name
Get-Process | Format-List -Property Name, BasePriority, PriorityClassIdentifyFormat all properties for a process
Get-Process winlogon | Format-List -Property *IdentifyTroubleshooting format errors
PC /> Get-Date | Format-List DayOfWeek, { $_ / $null } -DisplayError
DayOfWeek : Friday
$_ / $null : #ERR
PC /> Get-Date | Format-List DayOfWeek, { $_ / $null } -ShowError
DayOfWeek : Friday
$_ / $null :
Failed to evaluate expression " $_ / $null ".
+ CategoryInfo : InvalidArgument: (12/21/2018 7:59:23 AM:PSObject) [], RuntimeException
+ FullyQualifiedErrorId : PSPropertyExpressionErrorIdentifyIts page in the reference: Format-List.
Parameters
-DisplayErrorIndicates that this cmdlet displays errors at the command line. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a Format-List command, and the expressions do not appear to be working.-ExpandSpecifies the formatted collection object, as well as the objects in the collection. This parameter is designed to format objects that support the System.Collections.ICollection interface. The default value is EnumOnly. The acceptable values for this parameter are:
- EnumOnly. Displays the properties of the objects in the collection.
- CoreOnly. Displays the properties of the collection object.
- Both. Displays the properties of the collection object and the properties of objects in the
collection.-ForceIndicates that this cmdlet displays all the error information. Use with the DisplayError or ShowError parameter. By default, when an error object is written to the error or display streams, only some error information is displayed.
Also required when formatting certain .NET types. For more information, see the Notes section.-GroupBySpecifies the output in groups based on a shared property or value. Enter an expression or a
property of the output. The GroupBy parameter expects that the objects are sorted. Use the
Sort-Object cmdlet before using Format-List to group the objects.
The value of the GroupBy parameter can be a new calculated property. The calculated property can be a scriptblock or a hash table. Valid key-value pairs are:
- Name (or Label) - <string>
- Expression - <string> or <scriptblock>
- FormatString - <string>
For more information, see about_Calculated_Properties.-InputObjectSpecifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.-PropertySpecifies the object properties that appear in the display and the order in which they appear. Wildcards are permitted.
If you omit this parameter, the properties that appear in the display depend on the object being displayed. The parameter name Property is optional. You cannot use the Property and View parameters in the same command.
The value of the Property parameter can be a new calculated property. The calculated property can be a script block or a hash table. Valid key-value pairs are:
- Name (or Label) - <string>
- Expression - <string> or <scriptblock>
- FormatString - <string>
For more information, see about_Calculated_Properties.-ShowErrorIndicates that the cmdlet sends errors through the pipeline. This parameter is rarely used, but can be used as a debugging aid when you are formatting expressions in a Format-List command, and the expressions do not appear to be working.-ViewSpecifies the name of an alternate list format or view. You cannot use the Property and View parameters in the same command.