Format-List

 

Additional Resources for Format-List

 

Displaying Data as a List

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/format-list.mspx

 

 

SYNOPSIS

Formats the output as a list of properties in which each property appears on a new line.

 

SYNTAX

Format-List [[-property] <Object[]>] [-view <string>] [-groupBy <Object>] [-force] [-inputObject <psobject>] [-expand <string>] [-displayError] [-showError] [<CommonParameters>]

 

DETAILED DESCRIPTION

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. Because more space is available for each item in a list than in a table, Windows PowerShell displays more properties of the object in the list, and the property values are less likely to be truncated. You can use a command to format all properties of an object as a list (format-list *) to find all of the properties of the object.

 

PARAMETERS

 

-property <Object[]>

Specifies 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.

 

Required?

false

Position?

1

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-view <string>

Specifies the name of an alternate list format or "view." You cannot use the Property and View parameters in the same command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-groupBy <Object>

Formats the output in groups based on a shared property or value. Enter an expression or a property of the output.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-force <SwitchParameter>

Overrides restrictions that prevent the command from succeeding, just so the changes do not compromise security. For example, Force will override the read-only attribute or create directories to complete a file path, but it will not attempt to change file permissions.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-inputObject <psobject>

Specifies the objects to be formatted. Enter a variable that contains the objects or type a command or expression that gets the objects.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

true (ByValue)

Accept wildcard characters? 

false

 

-expand <string>

Formats the collection object, as well as the objects in the collection. This parameter is designed to format objects that support the ICollection (System.Collections) interface.

 

Valid values are:

 

·          Enum (default): Displays the properties of the objects in the collection.

·          Core: Displays the properties of the collection object.

·          Both: Displays the properties of the collection object and the properties of objects in the collection.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-displayError <SwitchParameter>

Displays errors at the command line.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-showError <SwitchParameter>

Sends errors through the pipeline.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

Object

 

RETURN TYPE

Formatted objects

 

NOTES

 

The format cmdlets, such as format-list, arrange the data to be displayed, but do not display it. The data is displayed by the output features of Windows PowerShell, and by the out-* cmdlets, such as Out-Host, Out-File, and Out-Printer.

 

If you do not use a format cmdlet, Windows PowerShell applies that default format for each object that it displays.

 

For more information, type "Get-Help Format-List -detailed". For technical information, type "Get-Help Format-List -full".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

You can also refer to Format-List by its built-in alias, "FL". For more information, see About_Alias.

 

The Groupby parameter assumes that the objects are sorted. Before using Format-Customto group the objects, use  Sort-Objectto sort them.

 

The View parameter lets you specify an alternate format for the table. You can use the views defined in the *.format.PS1XML files in the Windows PowerShell directory or you can create your own views in new PS1XML files and  use the Update-FormatDatacmdlet to include them in Windows PowerShell.

 

The alternate view for the View parameter must use list format; if not, the command fails. If the alternate view is a table, use Format-Table. If the alternate view is neither list nor table, use Format-Custom.

 

EXAMPLE 1

 

get-service | format-list

 

This command formats information about services on the computer as a list. By default, the services are formatted as a table. The Get-Servicecmdlet gets objects representing the services on the computer. The pipeline operator (|) passes the results through the pipeline to Format-List. Then, the Format-List command formats the service information in a list and sends it to the outputter for display.

 

EXAMPLE 2

 

$a = get-childitem $pshome\*.ps1xml

format-list -InputObject $a

 

These commands display information about the PS1XML files in the Windows PowerShell directory as a list. The first command gets the objects representing the files and stores them in the $a variable. The second command uses Format-List to format information about objects stored in $a. This command uses the InputObject parameter to pass the variable to Format-List, which then sends the formatted output to the outputter for display.

 

EXAMPLE 3

 

get-process | format-list -property name, basepriority, priorityclass

 

This command displays the name, base priority, and priority class of each process on the computer. It uses the Get-Processcmdlet to get an object representing each process. The pipeline operator (|) passes the process objects through the pipeline to Format-List. Format-List formats the processes as a list of the specified properties. The "-property" parameter name is optional, so you can omit it.

 

EXAMPLE 4

 

get-process winlogon | format-list -property *

 

This command displays all of the properties of the Winlogon process. It uses the Get-Process cmdlet to get an object representing the Winlogon process. The pipeline operator (|) passes the Winlogon process object through the pipeline to Format-List. The command uses the Property parameter to specify the properties and the * to indicate all properties. Because the name of the -property parameter is optional, you can omit it, and type the command as: "format-list *". Format-List automatically sends the results to the outputter for display.

 

RELATED LINKS

Format-Custom

Format-Table

Format-Wide

Out-Host

Out-File