7.3. Default Formatting
In pipelines that appear to have a single step, such as:
get-service
there is, in fact, an implicit final step in the pipeline, the default formatter. The visible step passes objects (in this case representing services) to a default formatter.
The default formatter for each cmdlet displays information that Microsoft perceives might be generally useful. Implicitly, the output is piped to the out-default cmdlet, which, in turn, pipes the output to the default formatter. The default formatter then displays output.
The file C:\WINDOWS\system32\windowspowershell\v1.0\powershellcore.format.ps1xml contains extensive information explaining how information about different types of objects is to be displayed (assuming that you installed Windows on drive C:). Figure 7-15 shows part of a copy of that file displayed in Internet Explorer. The elements refer to Microsoft.PowerShell.Commands.GroupInfo objects. Notice the presence of PropertyName elements, which are child elements of TableColumnItem elements. Three values are contained in those elements - Count, Name, and Group.
Figure 7.15. Figure 7-15
Execute the following command to demonstrate the default format from a pipeline using the group-object cmdlet as its last explicit step:
get-command | group-object verb
Notice in Figure 7-16 that the default formatting for output from the group-object cmdlet produces Count, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access