The Format-List cmdlet takes input from the pipeline and outputs a vertical columned list of all the specified properties of each object. You can specify which properties you want to display by using the Property parameter. If the Format-List cmdlet is called without any parameters specified, all properties are output. The Format-List cmdlet wraps lines instead of truncating them. One of the best uses for the Format-List cmdlet is to override the default output of a cmdlet so that you can retrieve additional or more focused information.
For example, when you call the Get-Mailbox cmdlet, you only see a limited amount of information in table format. If you pipe the output of the Get-Mailbox cmdlet to the Format-List cmdlet and add parameters for the additional or more focused information that you want to view, you can retrieve the output that you want.
You can also specify a wildcard character "*" with a partial property name. If you include a wildcard character, you can match multiple properties without having to type each property name individually. For example, Get-Mailbox | Format-List -Property Email* returns all properties that begin with Email.
The following examples show the different ways that you can view the same data returned by the Get-Mailbox cmdlet.
Get-MailBox TestUser1
Name Alias Server StorageQuota
---- ----- ------ ------------
TestUser1 TestUser1 e12 unlimited
In this first example, the Get-Mailbox cmdlet is called without specific formatting so the default output is in table format and contains a predetermined set of properties.
Get-Mailbox TestUser1 | Format-List -Property Name,Alias,EmailAddresses
Name : TestUser1
Alias : TestUser1
EmailAddresses : {SMTP:TestUser1@contoso.com, X400:c=US;a= ;p=Contoso;o=Exchange;s=TestUser1;}
Get-Mailbox TestUser1 | Format-List -Property Name, Alias, Email*
In the second example, the output of the Get-Mailbox cmdlet is piped to the Format-List cmdlet, together with specific properties. As you can see, the format and content of the output is significantly different.
Name : Test User
Alias : TestUser1
EmailAddresses : {SMTP:TestUser1@contoso.com, X400:c=US;a= ;p=First
Organization;o=Exchange;s=User;g=Test;}
EmailAddressPolicyEnabled : True
In the last example, the output of the Get-Mailbox cmdlet is piped to the Format-List cmdlet as in the second example. However, in the last example, a wildcard character is used to match all properties that start with Email.
If more than one object is passed to the Format-List cmdlet, all specified properties for an object are displayed and grouped by object. The display order depends on the default parameter for the cmdlet. This is most frequently the Name parameter or the Identity parameter. For example, when the Get-Childitem cmdlet is called, the default display order is file names in alphabetical order. To change this behavior, you must call the Format-List cmdlet, together with the GroupBy parameter, and the name of a property value by which you want to group the output. For example, the following command lists all files in a directory and groups these files by extension.
Get-Childitem | Format-List Name,Length -GroupBy Extension
Extension: .xml
Name : Config_01.xml
Length : 5627
Name : Config_02.xml
Length : 3901
Extension: .bmp
Name : Image_01.bmp
Length : 746550
Name : Image_02.bmp
Length : 746550
Extension: .txt
Name : Text_01.txt
Length : 16822
Name : Text_02.txt
Length : 9835
In this example, the Format-List cmdlet has grouped the items by the Extension property that is specified by the GroupBy parameter. You can use the GroupBy parameter with any valid property for the objects in the pipeline stream.