
Formatting Command Output
By default, when command output is displayed to the screen, the Exchange Management Shell displays only a subset of the available properties for each object. Why? Because each object can contain dozens of properties, and you'll want to optimize the command output for your needs. You can easily access and view all these properties by piping the output of a command to the following three formatting cmdlets: Format-List, Format-Table, and Format-Wide.
Format-List and Format-Table are most frequently used so let's look at them more closely.
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, which is a positional parameter. If you call the Format-List cmdlet 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, as in this example, Get-DistributionGroup | Format-List Name, *OnlyFrom, PrimarySmtpAddress, *Size*. Figure 2 shows the output of this command.
Figure 2 Format-List example output.gif)
The Format-Table cmdlet lets you display items in a table format with labeled headers and columns of property data. By default, many cmdlets, such as the Get-Mailbox and Get-JournalRule cmdlets, use the table format for output. Among the parameters for the Format-Table cmdlet are the Properties and GroupBy parameters. These work exactly as they do with the Format-List cmdlet. To display long lines of property information completely instead of truncating at the end of a line, use the Wrap parameter with the Format-Table cmdlet, as in the following example: Get-Mailbox -Database Research | Format-Table Name, ProhibitSendQuota, Database -Wrap. Figure 3 shows the output of this command.
Figure 3 Format-Table example output.gif)
You can also specify a wildcard character "*" with a partial property name with both the Format-List and Format-Table Cmdlets, as I showed in Figure 2. 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. Less typing and more time to play with Exchange 2007!