liveBook · Manning

Chapter 11: Formatting: And why it’s done on the right

What you will learn in chapter 11 of Learn PowerShell in a Month of Lunches: Fourth Edition, Covers Windows, Linux, and macOS

This introduction recaps how object properties and PowerShell’s defaults affect the output readers have seen so far.

After this chapter you will be able to

What it builds on

Section by section

Introduction

This introduction recaps how object properties and PowerShell’s defaults affect the output readers have seen so far.

Key terms: cmdlets, objects, properties, gm, Select-Object, default configuration and rules

11.1 Formatting: Making what you see prettier

Introduces formatting as the way to turn information collected with PowerShell into useful output, while noting that PowerShell is not a full-fledged reporting tool.

Key terms: formatting, output, reports

11.2 Working with the default formatting

This section explains how PowerShell turns objects into default text output, how it chooses a display, and why displayed column headers may differ from property names.

Key terms: Out-Default, Out-Host, Out-File, formatting system, formatting instructions, predefined view, .format.ps1xml, object type, table view, default display property set

11.3 Formatting tables

This section explains how to use Format-Table to choose table columns, group rows by a property, and preserve long values in the display.

Key terms: Format-Table, ft, -Property, wildcards, -GroupBy, property, -Wrap, ellipses

11.4 Formatting lists

Explains when to use Format-List and how it can reveal an object’s properties and their values.

Key terms: Format-List, fl, -Property, Format-Table, gm

11.5 Formatting wide lists

This section explains how Format-Wide displays one property in a multicolumn list and how to change its column count.

Key terms: Format-Wide, fw, -Property, Name, -Columns

11.6 Creating custom columns and list entries

Shows how formatting hash tables create custom table columns and list entries, including calculated values and display settings.

Key terms: Format-Table, Format-List, hash table, custom columns, custom list entries, Get-Process, VM, VM(MB), 1 MB, -as

11.7 Going out: To a file or to the host

This section explains how formatted output reaches the screen or a file, and why file output may need a wider character width.

Key terms: Format- cmdlet, formatting instructions, Out-Default, Out-Host, Out-File, -Width, character width

11.8 Another out: GridViews

This section introduces Out-GridView as graphical output that takes regular objects rather than formatted output.

Key terms: Out-GridView, formatting subsystem, Format- cmdlets, regular objects, Windows PowerShell, PowerShell 6+, PowerShell Gallery, module

11.9 Common points of confusion

Introduces two common formatting pitfalls that the following subsections will explain.

11.9.1 Always format right

This subsection explains why formatting belongs at the end of a PowerShell pipeline and why Out-File is the only useful exception.

Key terms: Format- cmdlet, formatting instructions, Out-File, Out-Default, Out-Host, Out-GridView, standard objects

11.9.2 One type of object at a time, please

This section explains why mixing object types in one pipeline can produce uneven formatting, while noting that predefined custom views are an exception.

Key terms: formatting system, pipeline, process objects, history objects, DirectoryInfo, FileInfo, predefined custom formatting view, Format-Custom

11.10 Lab

11.11 Lab answers

11.12 Further exploration

The section encourages readers to practice creating different output formats with the three main Format- cmdlets and their commonly used parameters.

Where this is used later

Concepts explained in this chapter

← Chapter 10: The pipeline, deeper Chapter 12: Filtering and comparisons →

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.